Coding Round 1
Mid
programming
**LeetCode #75 - Sort Colors** \nBackground: You are given an array consisting of red, white, and blue, represented by 0, 1, and 2 respectively. Your task is to sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. \nProblem Statement: Implement a function `void sortColors(int[] nums)` that sorts the array in a single pass with O(n) time complexity and O(1) space complexity. \nExample 1: \nInput: nums = [2,0,2,1,1,0] \nOutput: [0,0,1,1,2,2] \nExplanation: The numbers are sorted in order where 0 represents red, 1 represents white, and 2 represents blue. \nExample 2: \nInput: nums = [2,0,1] \nOutput: [0,1,2] \nConstraints: `1 <= nums.length <= 300`, `nums[i]` is either 0, 1, or 2.
Suggested Answer