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 };
本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/p/5110536.html,如需转载请自行联系原作者