Find a local minimum or peak with binary search

0
Remix

Find any local minimum of an array, an element no larger than its neighbours (treat positions outside the array as infinitely large), in O(log n) time. The same idea finds a peak element. Write it iteratively and explain why the half you discard is safe.

MetaCodingLast asked Aug 2026
No answer yet. Write the first one; the best answer gets endorsed.