Given an array containing only 0s, 1s, and 2s, sort the array in-place so that values appear in the order 0, 1, 2. Because the value range is tiny, counting or Dutch National Flag style partitioning is ideal.
nums = array containing only 0, 1, and 2
nums sorted in-place in 0-1-2 order
Example 1:
Input:
nums = [2,0,2,1,1,0]
Output:
[0,0,1,1,2,2]
Explanation:
The array is grouped by its three bounded values.
Example 2:
Input:
nums = [2,0,1]
Output:
[0,1,2]
Explanation:
A single pass can place each value into the correct region.