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