- skip the nonzero entries at the begining
- move the following nonzero entries to their final postions, if needed
- set zero at the end of the array

```
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int cur=0, len = nums.size(), i;
for(i=0; i<len && nums[i];++i); // step 1
for(cur=i++; i<len;++i) // step 2
if(nums[i]) nums[cur++] = nums[i];
while(cur<len) nums[cur++] = 0; // step 3
}
};
```