27. Sort Colors

nums contains only 0, 1 and 2 (red, white, blue). Sort it in place in one pass without using a library sort.

Example 1

Input: nums = [2,0,1,2,0]
Output: [0,0,1,2,2]

Example 2

Input: nums = [1]
Output: [1]
Hint 1

Keep three regions: 0s on the left, 2s on the right, 1s in the middle.

SortingTwo Pointers