easy C# solution


  • 0
    K
    public class Solution {
        public void SortColors(int[] nums) {
            
            int temp = 0;
            int len = nums.Length;
            for (int i=0;i<len-1;i++) {
                for (int j=i+1;j<len;j++) {
                    if (nums[i]>nums[j]) {
                        temp = nums[j];
                        nums[j] = nums[i];
                        nums[i] = temp;
                    }
                }
            }
        }
    }
    

Log in to reply
 

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