Skip to content

Instantly share code, notes, and snippets.

@hongtaoh
Created October 26, 2024 21:59
Show Gist options
  • Save hongtaoh/cf5cdf798c49ee71c31a5af4057f2a11 to your computer and use it in GitHub Desktop.
Save hongtaoh/cf5cdf798c49ee71c31a5af4057f2a11 to your computer and use it in GitHub Desktop.
Solution to Leetcode 283
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
l = 0
for r in range(len(nums)):
if nums[r] != 0:
nums[l], nums[r]= nums[r], nums[l]
l += 1
return nums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment