74. Search a 2D Matrix
Practice Search a 2D Matrix for free on NudgeCode: Medium, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Each row of matrix is sorted ascending, and the first value of each row is larger than the last value of the row above, so reading row by row gives one sorted sequence. Return whether target is in the matrix, in O(log(m * n)).
Example
matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3 -> true
matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13 -> false
Constraints
- 1 <= m, n <= 100
- -10^4 <= matrix[i][j], target <= 10^4