class Solution { public: bool Find(int target, vector<vector<int> > array) { int HangShu = array[0].size(); int LieShu = array.size(); int i = 0; int j = (LieShu - 1); int flag = 0; while ((i < HangShu) && (j >= 0)) { if (array[i][j] < target) { ++i; } else if (array[i][j]>target) { --j; } else { flag = 1; break; } } if (flag == 0) return false; else return true; } };
时间: 2024-12-14 02:46:45