题目链接:https://www.nowcoder.com/questionTerminal/abc3fe2ce8e146608e868a70efebf62e

题目大意:

  略

分析:

  对萌醒很开拓思维的一道题,从左下角开始找。

代码如下:

 1 class Solution {
 2 public:
 3     bool Find(int target, vector<vector<int> > array) {
 4         int n = (int)array.size(), m = (int)array[0].size();
 5         int i = n - 1, j = 0;
 6         while(i >= 0 && j < m) {
 7             if(array[i][j] == target) return true;
 8             if(array[i][j] < target) ++j;
 9             if(array[i][j] > target) --i;
10         }
11         return false;
12     }
13 };
View Code

相关文章:

  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2020-02-04
  • 2021-01-20
  • 2019-08-24
猜你喜欢
  • 2021-10-28
  • 2021-05-18
  • 2021-11-24
  • 2021-09-11
  • 2021-10-08
  • 2021-09-28
相关资源
相似解决方案