题解 | #二维数组中的查找#
二维数组中的查找
http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
public class Solution {
public boolean Find(int target, int [][] array){
//左上角
int x=array.length-1;
int y=0;
while(y<array[0].length && x>=0){
if(target<array[x][y])
x--;
else if(target>array[x][y])
y++;
else
return true;
}
return false;//其他返回都是false
}
}