0
点赞
收藏
分享

微信扫一扫

JZ4 二维数组中的查找

余寿 2022-04-13 阅读 39
c++
class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        int n=array.size();
        int m=array[0].size();
        if(!n||!m) return false;
        int t=0,r=n-1;
        while(t<n&&r>=0){
            if(target==array[t][r]){
                return true;
            }
            else if(target<array[t][r]){
                r--;
            }
            else t++;
        }
        return false;
    }
};
举报

相关推荐

0 条评论