Search a Valley Array
Problem statement
nums contains distinct values, strictly decreasing through one minimum and strictly increasing afterward. Return the index of target, or -1 if absent, in O(log n) time.
Function
searchValley(nums: int[], target: int) → intExamples
Example 1
nums = [10,4,3,2,5,6,8]target = 3return = 23 occurs on the decreasing side before the minimum 2.
Constraints
1 <= nums.length <= 10^5.