19. Search in Rotated Sorted Array
The integer array nums was sorted in ascending order and then rotated. Find the index of target in O(log n) time, or return -1 if it is absent.
範例 1:
輸入: nums = [4,5,6,7,0,1,2], target = 0 輸出: 4
範例 2:
輸入: nums = [4,5,6,7,0,1,2], target = 3 輸出: -1
限制條件:
1 <= nums.length <= 5000All values in nums are unique.