Sort an array A where each of the elements belong to the set: {0, 1, 2}.
Expected Time Complexity: O(n)
Try to solve it without storing the count of 0s, 1s and 2s.
A: [2, 2, 0, 1]
Result: [0, 1, 2, 2]
The first line contains an integer âTâ denoting the number of test cases.
For each test case the input has two lines:
A.A.For each test case, the output has a line containing n space separated integers denoting the elements of the sorted array A.
2
5
1 0 1 2 2
4
1 0 0 0
0 1 1 2 2
0 0 0 1
1 <= T <= 10
1 <= n <= 105
0 <= Ai <= 2