Search in Rotated Sorted Array II
mediumSearch a target in a rotated sorted array that may include duplicates
Search in Rotated Sorted Array II
Key Insight
Use normal rotated-array logic, but shrink both ends when duplicates block ordering.
Step 1Setup
Rotated with duplicates
L
R
2
05
16
20
30
41
52
6Search space: [0..6]
Find target in [2, 5, 6, 0, 0, 1, 2].
1 / 3