C++ 4 Lines concise code with parallel moving method


  • 1
    X
    void sortColors(vector<int>& nums) 
        {
            vector<int> table(3,0);
            for(auto it:nums)
                for(int i=2;i>=it;i--)
                    nums[table[i]++]=i;
        }

Log in to reply
 

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