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.

Input Format

An Integer N arr1 arr2.. n integers

Output Format

Check the sample output and question video.

Constraints

1 <= N <= 10000
arr[i] = 0,1,2

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
10
1
0
2
2
1
0
2
1
0
2
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
Previous
Sort 01
Next
Target Sum Pair 1

Related Questions