midSearching
Search in a Matrix where each row and column is sorted
Updated Apr 28, 2026
Short answer
Starting from top-right or bottom-left to eliminate a row/column at each step.
Deep explanation
Intermediate searching challenges involve non-standard data structures or specific constraints. Starting from top-right or bottom-left to eliminate a row/column at each step.
Real-world example
Finding a word in a partially organized document.
Common mistakes
- Using O(n) for a 2D matrix search when O(log(m*n)) is possible.
Follow-up questions
- Why is mid = (low + high) // 2 potentially dangerous?