Approach Summary
Treat the matrix as a flattened sorted array. Binary search on index 0..m*n-1, converting mid to (row, col) via division and modulo.
How to Recognize This Pattern
- Rows sorted, first element of each row > last of previous
- Binary search on virtual 1D array
Complexity Analysis
Time Complexity
O(log(m × n))
Space Complexity
O(1)
Tags
Array Binary Search Matrix