Easy C++ solution without STL


  • 0
    R
    public:
        void sortColors(vector<int>& nums) {
            int temp = 0;
            for(int i = 0; i < nums.size(); ++i){
                for(int j = 0; j < nums.size() - 1; ++j)
                    if(nums[i] < nums[j]){
                        temp = nums[i];
                        nums[i] = nums[j];
                        nums[j] = temp;
                    }
            }
        }
    };

Log in to reply
 

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