剑指offer——二维数组中的查找
二维数组中的查找
https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking
solution:
std:
class Solution {
public:
bool Find(int target, vector<vector<int> > array) {
int n = array.size();
int m = array[0].size();
int i = 0 ,j = m - 1;
while(i < n && j >= 0){
if(array[i][j] == target)
return true ;
if(array[i][j] > target)
j--;
else
i++;
}
return false;
}
};剑指offer 文章被收录于专栏
使用语言c++(比较喜欢用c++写编程题,java写的不熟)
腾讯成长空间 1100人发布

