https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/
选择右上角的,就能每次都排除一行或者一列
class Solution {
public:
bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) {
int n=matrix.size();
if(n==0)
return false;
int m=matrix[0].size();
if(m==0)
return false;
int r=0;
int c=m-1;
while(r<n && c>=0){
if(matrix[r][c]==target)
return true;
else if(matrix[r][c]<target){
r+=1;
}
else if(matrix[r][c]>target){
c-=1;
}
}
return false;
}
};