C# solution easy understand


  • 0
    C
    public void SortColors(int[] nums) {
            int temp = 0;
            for(int i=0;i<nums.Length-1;i++){
                for(int j=i+1;j<nums.Length;j++){
                    if(nums[i]>nums[j]){              //find bigger one switch
                        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.