ArrayTwo PointersSorting
An array contains only the values 0, 1 and 2 (think red, white and blue). Sort it in non-decreasing order. Try to do it in a single pass without calling a library sort.
Input
Line 1: n. Line 2: n values, each 0, 1 or 2.
Output
Print the sorted array on one line.
Constraints
1 <= n <= 10^5
Example 1
Input
6 2 0 2 1 1 0
Output
0 0 1 1 2 2
Two 0s, two 1s and two 2s in order.