题解 | #字符串字符匹配#
字符串字符匹配
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;
}
华为题库题解 文章被收录于专栏
牛客华为题库的题解