Algorithm · Uber · Medium
You are given an integer array nums. A position i is called a local minimum when nums[i] is strictly smaller than every adjacent element that exists. More precisely: For an interior position $$1 \le i \le n - 2$$, require $$nums[i] 1$$, require $$nums[n - 1] < nums[n - 2]$$. Return the leftmost index that satisfies the local-minimum condition. If no such index exists, return -1. An empty array also returns -1. Example 1: Explanation: nums[1] = 4 is less than both nums[0] = 7…
Checking your access…