Given an array of integer elements
*Your task is to*
ยท write a function that finds the minimum value X that makes
possible the following: generate a new array that is sorted in strictly
ascending order by increasing or decreasing each of the elements of the
initial array with
How about a normal binary search ?
We know that X can be [0, 2^31 - 1].
Also if X is a valid configuration, all the values above X will too.
Monotonicity is all we need here.
So, take lo = 0 and hi = 2 ^ 31 - 1.
Now check, if your mid is a valid X.
If yes, X can lie between [0, mid]. If not, X