1023. Camelcase Matching

挺好写的。

class Solution {
public:
    
    bool judge(string query, string pattern){
        if (query.size() < pattern.size()){
            return false;
        }
    
        int ii = 0;
        int jj = 0;
        while(ii<query.size()&&jj<pattern.size()){
            if (query[ii]==pattern[jj]){
                ii ++;
                jj ++;
            }
            else{
                if (query[ii]>='A'&&query[ii]<='Z'){
                    return false;
                }
                else{
                    ii ++;
                }
            }
        }
        
        if (ii==query.size()&&jj==pattern.size()){
            return true;
        }
        else if (ii<query.size()&&jj==pattern.size()){
            for (int kk = ii;kk<query.size();kk++){
                if (query[kk]>='A'&&query[kk]<='Z'){
                    return false;
                }
            }
            return true;
        }
        else if (ii==query.size()&&jj<pattern.size()){
            return false;
        }
        else{
            cout<<"error"<<endl;
            return false;
        }
    }
    
    vector<bool> camelMatch(vector<string>& queries, string pattern) {
        vector<bool> res;
        for (int i=0;i<queries.size();i++){
            res.push_back(judge(queries[i], pattern));
        }
        return res;
    }
};
1023. Camelcase Matching1023. Camelcase Matching zeroQiaoba 发布了339 篇原创文章 · 获赞 18 · 访问量 14万+ 私信 关注
上一篇:pta 乙级 1023 组个最小数 c++


下一篇:bzoj 1023 [SHOI2008]cactus仙人掌图