题目: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 };