[LeetCode] Move Zeroes (Python)
2024. 2. 29. 14:24ㆍ자료구조
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
zero = 0
for i in range(len(nums)):
if nums[i] != 0:
nums[i], nums[zero] = nums[zero], nums[i]
zero += 1
'자료구조' 카테고리의 다른 글
[LeetCode] Height Checker (Python) (0) | 2024.03.03 |
---|---|
[LeetCode] Sort Array By Parity (Python) (0) | 2024.02.29 |
[LeetCode] Replace Elements with Greatest Element on Right Side (Python) (0) | 2024.02.29 |
[LeetCode] Valid Mountain Array (Python) (0) | 2024.02.29 |
[LeetCode] Check If N and Its Double Exist (Python) (0) | 2024.02.29 |