← 返回 nvidia 的题目列表Search in Rotated Sorted Array
类型:online_judge
nvidia
Given a rotated sorted array with no duplicate elements, and a target value. Write a function to search the target in the array. If found, return its index, otherwise return -1. You can assume no duplicate exists in the array. Example: Input: nums = [4,5,6,7,0,1,2], target = 0 Output: 4 Input: nums = [4,5,6,7,0,1,2], target = 3 Output: -1 Constraints: The array length n won't exceed $10^4$.