← All problems
Search a 2D Matrix
Matrix with rows sorted and first-of-row > last-of-previous; search target.
Complexity
Time O(log(mn)), Space O(1)
Common pitfalls
- Row-by-row binary search (works, less elegant)
- Index mapping errors
Your solution
Log in to save your code and track progress.