题解 | #二维数组中的查找#官方解法妙啊
二维数组中的查找
http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
class Solution {
public:
bool Find(int target, vector<vector<int> > array) {
int n = array.size();
int m = array[0].size();
int a = 0;
int b = m - 1;
while(a < n && b >= 0){
if(array[a][b] == target){
return true;
}
else if(array[a][b] < target){
a++;
}
else if(array[a][b] > target){
b--;
}
}
return false;
}
};