Search in Rotated Sorted Array
mediumA sorted array has been rotated at some pivot. Search for a target value in O(log n) time
Search in Rotated Sorted Array
Key Insight
After rotation, one half around mid is always sorted. Check if target falls in the sorted half.
Step 1Initialize
Target: 0Rotated at index 4
L
R
4
05
16
27
30
41
52
6Search space: [0..6]
Rotated array. left=0, right=6. Looking for 0.
1 / 6