# 283. Move Zeroes

{% embed url="<https://leetcode.com/problems/move-zeroes/>" %}

`Two Pointer`双指针遍历，不停把`j`遍历到的非零项填进`i`位置，遇到0就跳过，最后在尾巴上补填0。在 candy crush 那题里也用过一样的技巧。

{% content-ref url="723.-candy-crush" %}
[723.-candy-crush](https://xuqiangwen1994.gitbook.io/practice/723.-candy-crush)
{% endcontent-ref %}

```python
class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        i, j = 0, 0
        while j < len(nums):
            if nums[j] != 0:
                nums[i] = nums[j]
                i += 1
            j += 1
        while i < len(nums):
            nums[i] = 0
            i += 1
        
        return nums
```
