Challenge Information

Title : Modify the Array
Difficulty : Medium
Solutions : 6
Maximum Score : 100
Completed by You: No
Description :

You have given a sorted array of positive integers. You have to rearrange the array elements according to the following instructions:

-First element should be the maximum value.
-Second element should be the minimum value.
-Third element should be the second maximum value.
-Fourth element should be the second minimum value and, so on

Write a function solve that have the following parameter(s):
1.) arr = array of integers

Example
Input:
There is an array of integers:
[1,2,3,4,5]
Output:
The function will return,
[5, 1, 4, 2, 3]

Explanation
Max element = 5, min = 1, second max = 4, second min = 2, and so on... Modified array is : [5,1,4,2,3].

Constraints

Judocode