Stage 1 · Code
Stack & Binary Search
Rotated & 2D Search
Binary search when the sorted array has been rotated or arranged in a 2D matrix.
7 min readLeetCode Patterns for InterviewsCode
The Pattern
In a rotated sorted array, one half is always sorted. Determine which half is sorted, check if target is in that half, then eliminate the other half. For 2D matrix search, use lo=0, hi=m*n-1 and convert index to row/col.
Rotated sorted array — pivot at index 3 where the rotation occurs
4
5
6
7pivot
0
1
2
0
1
2
3
4
5
6
Problems
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.