Find Peak Element (LC #162) shows binary search works on unsorted arrays. A peak is greater than its neighbors. Compare arr[mid] with arr[mid+]. If mid is greater, a peak exists on the left (including mid). Otherwise a peak exists on the right. Runs in time. Why does this work? We're searching for any peak, not a specific value. The comparison tells us which direction guarantees a peak. Meta asks a variant: find a valley element instead. Same logic, reversed comparison.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/sorting-searching/find-peak-element
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████████████