Search A 2d Matrix - 2
medium
1. Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties: a). Integers in each row are sorted in ascending from left to right. b). Integers in each column are sorted in ascending from top to bottom.
Constraints
m == matrix.length n == matrix[i].length 1 <= n, m <= 300 -10^9 <= matix[i][j] <= 10^9 -10^9 <= target <= 10^9
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
5 5
1 4 7 11 15
2 5 8 12 20
4 6 9 16 22
10 13 14 17 24
18 21 23 26 30
12
Sample Output
true
Question Video