(1)二分法
public class Solution {
public boolean searchMatrix(int[][] matrix, int target) {}
矩阵从右上角到左下角遍历
public class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
int d=0;
int a=matrix.length-1;
int b=matrix[0].length-1;
while(b>=0&&d<=a)
{
int c=matrix[d][b];
if(c==target)
{
return true;
}
if(c>target)
{
b--;
}
else
{
d++;
}
}
return false;
}
}