Answer to Question #309409 in Algorithms for Akash srivastava

Question #309409

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




0
Service report
It's been a while since this question is posted here. Still, the answer hasn't been got. Consider converting this question to a fully qualified assignment, and we will try to assist. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS