283. Move zeros
- more of a implementation type problem
naive type implementation
```cpp
class Solution {
public:
void moveZeroes(vector& nums) {
vector ans;
int count = 0;
for (int i = 0; i < nums.size(); i++) {
if (nums[i]) {
ans.push_back(nums[i]);
}
else {
count ++;
}
}
while (count--) ans.push_back(0);
swap(ans, nums);
}
};
```
</details>
more concise
```cpp
class Solution {
public:
void moveZeroes(vector& nums) {
int j = 0;
for (int i = 0; i < nums.size(); i++) {
if (nums[i]) {
nums[j++] = nums[i];
}
}
for (; j < nums.size(); j++) {
nums[j] = 0;
}
}
};
```
</details>