You are given an m x n integer matrix with two properties:
Return true if target appears in the matrix and false otherwise.
Input / output
matrix: int[][], target: intbooleanExamples
matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3 returns true.matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13 returns false.matrix = [[1]], target = 1 returns true.Constraints
1 <= m, n <= 100-10000 <= matrix[i][j], target <= 10000Edge cases
Target complexity
O(log(m * n)) time and O(1) extra space.Hints
i to matrix[i / n][i % n] to run a single binary search.Follow-up If only rows (but not the row-boundaries) were sorted, what search strategy would you use instead?