Search a Row-and-Column Sorted Matrix
Problem statement
Return whether target occurs in matrix. Rows are nondecreasing left to right, and columns are nondecreasing top to bottom. Values may repeat. The flattened matrix need not be sorted; an empty matrix or a matrix with zero columns contains no value.
Function
searchSortedMatrix(matrix: int[][], target: int) → booleanExamples
Example 1
matrix = [[1,4,7],[2,5,9],[3,6,10]]target = 6return = trueValue6 is at row2,column1 using zero-based coordinates.
Example 2
matrix = [[1,4,7],[2,5,9]]target = 8return = falseEight is absent even though it lies between existing values.
Constraints
0 <= matrix.length <= 100.0 <= matrix[r].length <= 100.-1000000 <= matrix[r][c] <= 1000000.-1000000 <= target <= 1000000.- All rows have equal length, and every row and every column is nondecreasing.