Meta VO Interview Question: Find Any Local Minimum in an Array

16 Views
No Comments

Given an array of integers, find any one local minimum in the array. A local minimum is defined as an integer in the array that is less than or equal to its neighbors.

Example:

[5, 9, 11, 14, 7, 8] -> return 5 or 7

This problem asks for any local minimum in an integer array, meaning an element that is less than or equal to its neighbors. A standard solution uses binary search on the array’s slope: compare the middle element with its adjacent values and move toward the side that must contain a local minimum. This gives an efficient O(log n) approach, with boundary cases handled directly when needed.

END
 0