Given an array , in which either the values are only increasing or only decreasing or increasing and then decreasing, How to find the max and min value of such and array?
min value is nothing but the smallest of the end values.
but how to find max value?
One way is the linear approach with running time of O(n), can this be solved in O(logn), using some modification to the binary search?
Any code (in java) is highly appreciated.
Thanks
Nohsib
1 Answer