← All problems

Search a 2D Matrix

Medium searchingmatrix LeetCode ↗
Matrix with rows sorted and first-of-row > last-of-previous; search target.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.