题解 | 字符串字符匹配

字符串字符匹配

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

// 活动地址: 牛客春招刷题训练营 - 编程打卡活动
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

void solve(){
   string a,b;
   cin>>a>>b;
    // 又是非常典的一题 求一个字符串内的所有字符是否出现在另外一个字符串中
    // 煮波分别 用count 函数 和 find 函数都写了 
    // 具体细节读者自己领悟哈哈
   for(auto &x:a){
    if(b.find(x)==string::npos){
        cout<<"false";
        return ;
    }
   }
//    for(auto x:a){
//        if(count(b.begin(),b.end(),x)==0){
//         cout<<"false";
//         return ;
//        }
//    }  
   
   cout<<"true"<<"\n";
}

int main(){
    int T=1;
    while(T--){
        solve();
    }
    return 0;
}
// 活动地址: 牛客春招刷题训练营 - 编程打卡活动

全部评论

相关推荐

点赞 评论 收藏
分享
群星之怒:不是哥们,你就不好奇瘫痪三十年的老植物人是啥样的吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务