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