题目:http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e

C++

 1 class Solution {
 2 public:
 3     bool Find(vector<vector<int> > array,int target) {
 4         int rows = array.size();
 5         int cols = array[0].size();
 6         int x = cols - 1;
 7         int y = 0;
 8         while ( x >= 0 && y < rows ) {
 9             if (array[x][y] == target) return true;
10             if (array[x][y] < target) y++;
11             if (array[x][y] > target) x--;
12         }
13         return false;
14     }
15 };

 

相关文章:

  • 2021-11-28
  • 2021-05-15
  • 2021-11-29
  • 2021-11-07
  • 2022-02-10
  • 2021-09-18
猜你喜欢
  • 2021-10-15
  • 2021-06-07
  • 2021-03-31
  • 2022-01-11
  • 2021-06-06
  • 2021-06-17
  • 2021-12-09
相关资源
相似解决方案