Medium
Quiz
#33 Search in Rotated Sorted Array
APPROACH
An ascending-sorted array nums of distinct integers was rotated at an unknown pivot. Search for target in the rotated array and return its index, or -1 if absent. The solution must run in O(log n) time.
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
1 of 4
1:00
What is the optimal approach for this problem?