题解 | #二维数组中的查找 从最右上角开始#
二维数组中的查找
http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
class Solution {
public:
bool Find(int target, vector<vector<int> > array) {
int row = array.size(), column = array[0].size();
int i = 0, j = column-1;
bool flag = false;
while(i < row && j >= 0){
if(array[i][j] == target)
{flag = true; break;}
if(array[i][j] < target)
++i;
else
--j;
}
return flag;
}
};