One line solution using stable_partition STL algorithm


  • 0
    W
    class Solution {
    public:
        void moveZeroes(vector<int>& nums) {
            stable_partition(nums.begin(), nums.end(), [](int x) {return x != 0;});
        }
    };

Log in to reply
 

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