题解 | #二维数组中的查找#

二维数组中的查找

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

public:
    bool Find(int target, vector<vector<int> > array) {
        int m=array.size()-1;
        int n=array[0].size()-1;
        int up=0,right=n;
        int temp=array[up][right];
        while(up<=m&&right>=0){
            if(temp==target){
                return true;
            }else if(temp>target){
                right--;
            }else{
                up++;
            }
            temp=array[up][right];
        }
        return false;
    }
};
全部评论

相关推荐

04-13 11:19
门头沟学院 HTML5
NullPointe...:27实习的都快结束了吧
点赞 评论 收藏
分享
allin春招的安哥...:你这个简历哪个神仙教的,面试官压根不看简历,你搞两页给人家看,第一印象你就废掉了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务