题解 | #二维数组中的查找#
二维数组中的查找
https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=265&tqId=39208&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D265&difficulty=undefined&judgeStatus=undefined&tags=&title=
class Solution { public: //从右上角开始查询 bool Find(int target, vector<vector<int> >& array) { int i=0,j=array[0].size()-1; while(i<array.size() && j>=0) { if(target > array[i][j]) { i++; } else if(target < array[i][j]) { j--; } else { return true; } } return false; } };