Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- void moveZeroes(vector<int>& nums) {
- int n=nums.size(), k=0;
- for(auto it=nums.begin();it!=nums.end();++it){
- if(*it==0){
- k++;
- nums.erase(it);
- it--;
- }
- }
- for(int i=0;i<k;i++){
- nums.push_back(0);
- }
- for(auto & It : nums){
- cout<<It<<",";
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement