admin@onlinelearningcenter.in (+91) 7 999 01 02 03

Make a Pair of Maximum and Minimum number pair of given array

Jaivik Shah
6 Posts

Write a Java/Scala program to sort an array of positive integers of a given array, in the sorted array the value of the first element should be maximum, second value should be minimum value, third should be second maximum, fourth second be second minimum and so on.

 

Sample Pattern:
[100, 10, 90, 20, 80, 30, 70, 40, 60, 50]


Input:
Original Array 
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

Output:
New Array 
[100, 10, 90, 20, 80, 30, 70, 40, 60, 50]

 

Published By : Jaivik Shah
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin