题解 | #字符串字符匹配#

字符串字符匹配

http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

#include <bits/stdc++.h>

using namespace std;

bool process(string s1, string s2){
    unordered_set<char> s;

    for(int i = 0; i < s1.size(); i++){
        s.insert(s1[i]);
    }
    for(int i = 0; i < s2.size(); i++){
        if(s.find(s2[i]) != s.end())
            s.erase(s2[i]);
    }
    
    if(s.empty()){
        return true;
    }
    
    return false;
}

int main(){
    string _short = "";
    string _long = "";
    cin >> _short;
    cin >> _long;
    
    bool res = process(_short, _long);
    if(res)
        cout << "true" << endl;
    else
        cout << "false" << endl;
    
    return 0;
}
华为题库题解 文章被收录于专栏

牛客华为题库的题解

全部评论

相关推荐

高斯林的信徒:武大简历挂?我勒个骚岗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务