class Solution { public: bool Find(int target, vector<vector<int> > array) { //因为题目的属性可以知道用右上角的元素判断,如果右上角的元素 //大于target数值,就减一列,如果小于就减一行 int row = array.size(); int column = array[0].size(); int i=0; int j=column-1; while(i<row&&j>=0){ if(array[i][j]==target) return true; else if (array[i][j]>target) j--; else i++; } return false; } };
标签:二分,return,target,int,---,查找,array,size From: https://www.cnblogs.com/jerry-autumn/p/16600310.html