Search a sorted matrix
Mediumbinary searchmatrix
Each row of matrix is sorted ascending, and each row's first number is larger than the previous row's last. Return true if target is present, in O(log(m·n)).
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
Constraints
- 1 ≤ rows, cols ≤ 100
- -10⁴ ≤ values, target ≤ 10⁴
Submit checks your solution against 10 tests, including hidden ones.
/**
* @param {int[][]} matrix
* @param {int} target
* @return {bool}
*/
function searchMatrix(matrix, target) {
}