Fast one-line C++ solution


  • 1
    F
    class Solution {
    public:
        void moveZeroes(std::vector<int>& nums) {
            std::stable_partition(begin(nums), end(nums), [](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.