C++ solution; Any improvements?


  • 0
    P

    class Solution {
    public:
    void moveZeroes(vector<int>& nums) {
    vector<int>::iterator p;
    for(p=nums.end()-1;p>=nums.begin();p--){
    if(!(*p)) {
    nums.erase(p);
    nums.push_back(0);
    }
    }
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.