Search a rotated list
Mediumbinary searcharray
An ascending list of distinct values was rotated at an unknown point ([0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Return the index of target or -1, in O(log n).
Example 1
Input: nums = [4,5,6,7,0,1,2], target = 0 Output: 4
Example 2
Input: nums = [4,5,6,7,0,1,2], target = 3 Output: -1
Example 3
Input: nums = [1], target = 0 Output: -1
Constraints
- 1 ≤ nums.length ≤ 5000
- Values are distinct
Submit checks your solution against 10 tests, including hidden ones.
/**
* @param {int[]} nums
* @param {int} target
* @return {int}
*/
function searchRotated(nums, target) {
}