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