06
How would you search in a rotated sorted array?
Tap to write answer
0 words | 0 charsPress Enter ↵ to reveal
Your Attempt
0 wordsRefined Model Answer
ReferenceI would use binary search, but I would first identify which half of the array is properly sorted at each step. Once I know the sorted side, I can decide whether the target belongs there or in the other half. The reason I choose this approach is that it keeps the time complexity at O(log n). I would also mention edge cases like arrays with one element, no rotation, and the possibility of duplicates if the interviewer includes them. If duplicates are allowed, I would explain that the logic becomes a little more careful because the sorted side is not always obvious.