Problem of the day
For βarrβ = {1, 0, 0, 2, 1}.
βAnswerβ = {0, 0, 1, 1, 2}.
βAnswerβ should contain all 0s first, then all 1s and all 2s in the end.
The first line contains an integer βTβ, denoting the number of test cases.
For each test case:
The first line contains an integer βNβ, representing the size of the array βarrβ.
The second line contains βNβ integers, denoting the elements of the array βarrβ.
For each testcase, return an array βAnswerβ which contains all the elements of βarrβ in sorted order.
1 <= βTβ <= 10^5
1 <= βNβ <= 10^5
0 <= βarr[i]β <= 2
Sum of βNβ for all testcases <= 10^5
Time Limit: 1 sec
2
4
1 2 0 1
3
1 0 1
0 1 1 2
0 1 1
For Test 1:
For βarrβ = {1, 2, 0, 1}.
βAnswerβ = {0, 1, 1, 2}.
In βAnswer all 0 is placed first, then all the 1s and finally 2.
For Test 2:
For βarrβ = {1, 0, 1}.
βAnswerβ = {0, 1, 1}.
In βAnswer all 0 is placed first, then all the 1s.
2
4
0 1 1 2
3
2 1 1
0 1 1 2
1 1 2