How to Solve Max-Min Arrays in Java
The challenge
You are given an array of unique elements, and your task is to rearrange the values so that the first max value is followed by the first minimum, followed by second max value then second min value, etc.
For example:
|
|
The first max is 15
and the first min is 7
. The second max is 12
and the second min is 10
and so on.
The solution in Java code
Option 1:
|
|
Option 2:
|
|
Option 3:
|
|
Test cases to validate our solution
|
|