题解 | #二维数组中的查找#
二维数组中的查找
https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
public class Solution {
public boolean Find(int target, int [][] array) {
int m=array.length;
if(m==0) return false;
int n=array[0].length;
int i=0,j=n-1;
while(i<m&&j>=0){
if(array[i][j]==target) return true;
if(array[i][j]>target) j--;
else i++;
}
return false;
}
}
public boolean Find(int target, int [][] array) {
int m=array.length;
if(m==0) return false;
int n=array[0].length;
int i=0,j=n-1;
while(i<m&&j>=0){
if(array[i][j]==target) return true;
if(array[i][j]>target) j--;
else i++;
}
return false;
}
}