You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are given an integer array/list(ARR) of size N. It contains only 0s, 1s and 2s. Write a solution to sort this array/list in a 'single scan'.
4
+
'Single Scan' refers to iterating over the array/list just once or to put it in other words, you will be visiting each element in the array/list just once.
5
+
Note:
6
+
You need to change in the given array/list itself. Hence, no need to return or print anything.
7
+
Input format :
8
+
The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow.
9
+
10
+
First line of each test case or query contains an integer 'N' representing the size of the array/list.
11
+
12
+
Second line contains 'N' single space separated integers(all 0s, 1s and 2s) representing the elements in the array/list.
13
+
Output Format :
14
+
For each test case, print the sorted array/list elements in a row separated by a single space.
15
+
16
+
Output for every test case will be printed in a separate line.
0 commit comments