Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

283. 移动零 #21

Open
mentaLwz opened this issue Nov 19, 2020 · 0 comments
Open

283. 移动零 #21

mentaLwz opened this issue Nov 19, 2020 · 0 comments
Labels
Leetcode2020 2020含泪刷的题

Comments

@mentaLwz
Copy link
Owner

class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        slow, fast = 0, 0

        while fast < len(nums):
            if nums[fast] != 0:
                nums[slow] = nums[fast]
                slow += 1
                fast += 1
            else:
                fast += 1
        
        while slow < len(nums):
            nums[slow] = 0
            slow += 1
@mentaLwz mentaLwz added the Leetcode2020 2020含泪刷的题 label Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Leetcode2020 2020含泪刷的题
Projects
None yet
Development

No branches or pull requests

1 participant