在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数

class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
    if(array.empty()) return false
        int rows = array.size(); 
        int columns = array[0].size(); 
        bool found = false
        int x = 0, y = columns - 1
        while(x>=0 && x < rows && y >=0 && y < columns){ 
            if(array[x][y] == target){ 
                return true
            
            if(array[x][y] > target) y--; 
            if(array[x][y] < target) x++; 
        
        return found;
    }
};
posted @ 2017-06-04 18:21  czcColud  阅读(442)  评论(0)    收藏  举报