Simple mountain
Input
arr = [1,2,3,4,3,2,1]
Output
3
The peak value 4 is at index 3.
Full lesson preview
Locate the peak index in a mountain (bitonic) array in O(log n) time.
Problem statement
Task
Examples
Input
arr = [1,2,3,4,3,2,1]
Output
3
The peak value 4 is at index 3.
Input format
Output format
Constraints
Samples
Input
arr = [0,2,1,0]
Output
1
2 is the peak at index 1.