题解 | 字符串字符匹配
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include <iostream>
#include<map>
using namespace std;
map<char,bool>mp;
int main() {
string s1,s2;cin>>s1>>s2;
for(int i = 0;i<s2.length();i++){
mp[s2[i]] = true;
}
int ok = 0;
for(int i = 0;i<s1.length();i++){
if(!mp[s1[i]]){
cout<<"false\n";
return 0;
}
}
cout<<"true\n";
return 0;
}
// 64 位输出请用 printf("%lld")
遍历t,然后维护一个map即可,如果s中没有直接输出即可。
活动地址https://www.nowcoder.com/discuss/726480854079250432
#牛客春招刷题训练营#