01_二维数组中的查找

1、题目描述


2、解题思路

程序在,如下网址验证

https://www.nowcoder.com/ta/coding-interviews?page=1

class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        
        for(int i=0; i<array.size(); i++)
        {
            for(int j=0; j<array[i].size(); j++)
            {
                if(target < array[i][j])
                {
                    break;
                }
                else if(target == array[i][j])
                {
                    return true;
                }
            }
        }
        return false;
    }
};

猜你喜欢

转载自blog.csdn.net/sea_snow/article/details/80915112
今日推荐