Sort 012
easy
1. You are given an array(arr) containing only 0's, 1's, and 2's. 2. You have to sort the given array in increasing order and in linear time.
Constraints
1 <= N <= 10000 arr[i] = 0,1,2
Format
Input
An Integer N arr1 arr2.. n integers
Output
Check the sample output and question video.
Example
Sample Input
10
1
0
2
2
1
0
2
1
0
2
Sample Output
Swapping index 1 and index 0
Swapping index 2 and index 9
Swapping index 2 and index 8
Swapping index 2 and index 1
Swapping index 3 and index 7
Swapping index 5 and index 2
Swapping index 6 and index 6
0
0
0
1
1
1
2
2
2
2
Question Video