← 返回 meta 的题目列表Find Local Element Strictly Lower Than Neighbors
类型:online_judge
Given an integer array nums, write a function to find a local element that is strictly lower than its neighbors. You can assume nums[-1] and nums[n] are negative infinity. Return the index of that local element. The algorithm must run in logarithmic time complexity.
Example
Example 1:
Input: `nums = [1, 3, 2, 4, 3]`
Output: `4`
Example 2:
Input: `nums = [6, 4, 5]`
Output: `1`
Constraints
1 <= nums.length <= 1000
-10^4 <= nums[i] <= 10^4
nums[i] != nums[i + 1]
Example
Input
5
1 3 2 4 3