Description
Submission
class Solution { public: void moveZeroes(vector<int>& nums) { int n = nums.size(); for(int i = 0, j = 0; i < n && j < n; ) { if(nums[i] == 0) { while(j < n && nums[j] == 0) ++j; if(j >= n) break; nums[i] = nums[j]; nums[j] = 0; } else { ++i; j = max(i, j); } } } };