题解 | #二维数组中的查找#
二维数组中的查找
https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
class Solution { public: bool Find(int target, vector<vector<int> > array) { int col=array.size();//求行数 int row=array[0].size();//求列数 int x=0;//列坐标 int y=col-1;//行坐标 while(x<row && y>=0) { if(target>array[y][x]) { x=x+1; } else if(target<array[y][x]) { y--; } else { return true; } } cout<<"11111111"<<endl; return false; } };