解题思路:
从左下角开始,根据条件删除行和列。
class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
int row = matrix.length - 1;
int col = matrix[0].length - 1;
int l = 0;
while (row >= 0 && l <= col) {
if (target < matrix[row][l]) {
row--;
} else if (target > matrix[row][l]) {
l++;
} else {
return true;
}
}
return false;
}
}