c++ 2 line solution with no loops


  • 1
    G
    class Solution {
    public:
        void moveZeroes(vector<int>& nums) {
            auto start = remove_if(nums.begin(), nums.end(), [](const int& x){ return x == 0; });
            fill(start, nums.end(), 0);
        }
    };
    

Log in to reply
 

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