Dashboard
LC #33
Search in Rotated Sorted Array
Pattern · ?AmazonGoogleMetaBloombergMicrosoft
Problem
Search a target in a sorted array that has been rotated at some unknown pivot.
Constraints
- 1 ≤ n ≤ 5000
- -10⁴ ≤ nums[i] ≤ 10⁴
- All values are unique
- O(log n) runtime required
Example
- Input
- nums = [4, 5, 6, 7, 0, 1, 2], target = 0
- Output
- 4
- Why
- Array rotated at pivot index 4. 0 is at index 4
Spot the pattern
Which pattern cracks it?
Hints
One at a time