Basic rotated search
Input
nums = [4,5,6,7,0,1,2], target = 0
Output
4
0 appears at index 4 in the rotated array.
Full lesson preview
Find the index of a target in a rotated sorted array using O(log n) time.
Problem statement
Task
Examples
Input
nums = [4,5,6,7,0,1,2], target = 0
Output
4
0 appears at index 4 in the rotated array.
Input format
Output format
Constraints
Samples
Input
nums = [6,7,1,2,3,4,5], target = 3
Output
4
3 is at index 4.