Back to problems

Find a Local Minimum (Valley) in an Array

Algorithm · Meta · Medium

You are given an integer array nums of length n. Your job is to report an index at which a local minimum occurs; when more than one such index exists, returning any one of them is acceptable. An entry qualifies as a local minimum if it is strictly less than each neighbor it actually has. Neighboring entries are guaranteed to differ from one another, so adjacent ties never happen. Any position just before the first element or just past the last element behaves as though it…

Checking your access…