Search a 2D Matrix
Medium
LC #74
binary searchmatrixNot attempted yet
You're given an m x n integer matrix where:
- each row is sorted ascending, and
- the first value of each row is greater than the last value of the row above.
Return True if target is in the matrix, else
False. Aim for O(log(m * n)) time.
Example 1
Input: matrix = [[1,3,5,7],
[10,11,16,20],
[23,30,34,60]]
target = 3
Output: True
Example 2
Input: matrix = [[1,3,5,7],
[10,11,16,20],
[23,30,34,60]]
target = 13
Output: False
Example 3
Input: matrix = [[1]], target = 1
Output: True
Constraints
- 1 <= m, n <= 300
- -10^4 <= matrix[i][j], target <= 10^6