Sort Array Problem Statement
Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.
Input:
Each input starts with an integer T, the number of test cases. For each test case, the first line contains an integer N, the size of the array. The second line contains N space-separated integers which are elements of the array.
Output:
For each test case, output the sorted array of N integers in a separate line.
Example:
Input:
2
5
0 2 1 2 0
3
2 1 0
Output:
0 0 1 2 2
0 1 2
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 10^4
0 ≤ arr[i] ≤ 2
, where arr[i] is the array element at index 'i'.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Be the first one to answer
Add answer anonymously...
Top Siemens Front end Developer interview questions & answers
Popular interview questions of Front end Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app