nums contains 0s, 1s and 2s representing red, white and blue. Return the array sorted so equal colours are adjacent, in the order red, white, blue.
nums
0
1
2
nums = [2,0,2,1,1,0]
[0,0,1,1,2,2]
nums = [2,0,1]
[0,1,2]
1 <= nums.length <= 300 `nums[i]` is `0`, `1` or `2`.
Topics
Implement sortColors in the editor and return the answer — printing it is never graded.
sortColors
Problem 77 of 1146 in the arena