My first instinct was a linear scan and I actually started explaining it before catching myself.
Use a binary search approach by comparing the middle element with its neighbors to determine which half contains a local minimum. If the middle element is greater than its right neighbor, a local minimum must exist in the right half; otherwise, it exists in the left half (including the middle). Continue narrowing down until you find a local minimum.
Pro tip: Explicitly handle edge cases (array of size 1 or 2) and clarify that the algorithm works because the array can be thought of as having virtual -∞ boundaries, guaranteeing a local minimum exists. This shows attention to detail and deep understanding.
Confirm that the array is non-empty, elements are distinct? (Not necessarily, but strict inequality means no equal neighbors). Discuss edge cases: single element, two elements, and boundaries.
Describe how to use binary search: at each step, compare the middle element with its neighbors. If it's a local minimum, return its index. Otherwise, decide which half to search based on the slope.
If mid > mid+1, then a local minimum exists in the right half (including mid+1). Else if mid > mid-1, then a local minimum exists in the left half (including mid-1). Otherwise, mid itself is a local minimum.
Adjust comparisons for the first and last elements. Ensure the loop terminates when the search space reduces to one element, which must be a local minimum.
State that the time complexity is O(log n) due to halving the search space each iteration, and space complexity is O(1). Walk through a small example to verify correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.