Watson gives Sherlock an array of integers. Given the endpoints of an integer range, for all in that inclusive range, determine the minimum( abs(arr[i]-M) for all ) ). Once that has been determined for all integers in the range, return the which generated the maximum of those values. If there are multiple 's that result in that value, return the lowest one.
For example, your array and your range is from to inclusive.
We look at the Min column and see the maximum of those three values is . Two 's result in that answer so we choose the lower value, .
Complete the sherlockAndMinimax function in the editor below. It should return an integer as described.
sherlockAndMinimax has the following parameters:
- arr: an array of integers
- p: an integer that represents the lowest value of the range for
- q: an integer that represents the highest value of the range for
The first line contains an integer , the number of elements in .
The next line contains space-separated integers .
The third line contains two space-separated integers and , the inclusive endpoints for the range of .