Sort an Array of 0s, 1s and 2s
Given an array containing only 0s, 1s, and 2s, sort it in a single pass without using a library sort function.
Input format
The first line contains N. The second line contains N integers, each 0, 1, or 2.
Output format
Print the array sorted in non-decreasing order, space-separated on one line.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
6
0 2 1 2 0 1Expected output
0 0 1 1 2 2Example 2
Input
3
2 2 2Expected output
2 2 2