Peak Index in a Mountain Array
Medium · Binary Search · about 10 minutes
Asked at Amazon, Google, Bloomberg, Qualcomm, Meta, AMD, Broadcom, Samsung, Micron, Nutanix.
A mountain array strictly increases to a single peak and then strictly decreases (length ≥ 3). Return the index of the peak in O(log n) time.