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

查看14道真题和解析
CVTE公司福利 732人发布