Wave array
Time Limit: 2 sec
Memory Limit: 128000 kB
Problem Statement
Given an N size array of unique inyegers, your task is to print the array in a wave form, i. e a1 >= a2 <= a3 >= a4 <= a5.. . print the lexicographically smallest array possible.
Input
First line of input contains a single integer N, next line contains N space separated integers depicting the values of the array.
Constraints:-
1 < = N < = 100000
1 < = Arr[i] < = 1000000000
Output
Print the array in wave form as mentioned.
Example
Sample Input :-
5
2 1 3 5 4
Sample Output:-
2 1 4 3 5
Comments
Leave a comment