题解 | 字符串字符匹配

#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

int main() {
    unordered_map<char,char> hash;
    string s,t;
    cin>>s;
    cin>>t;
    int i = 0,j = 0;
    int sl = (int)s.length();
    int tl = (int)t.length();
    for(i = 0; i<tl; i++){
        hash.insert({t[i], t[i]});
    }
    for(j = 0; j<sl; j++){
        auto got = hash.find(s[j]);
        if(got == hash.end()){
            cout<< "false"<<endl;
            return 0;
        }
    }
    cout<< "true" <<endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

11-13 10:17
门头沟学院 Java
昨天面美团,jvm,juc问的好深啊,感觉小林coding不太够喔,牛油们有没有什么推荐的八股网站嘛🕒&nbsp;岗位/面试时间👥&nbsp;面试题目🤔&nbsp;面试感受
明天不下雨了:小林Coding:https://xiaolincoding.com/ 全栈哥:https://www.pdai.tech/ Guide哥:https://javaguide.cn/ 秀哥:https://interviewguide.cn/ 沉默王二:https://javabetter.cn/home.html 磊哥:https://www.javacn.site/interview/basic/ 小傅哥:https://bugstack.cn/ 源码哥:https://doocs.github.io/source-code-hunter/#/ 各大厂的公众号技术文章和一些经典的书籍
面试太紧张了怎么办?
点赞 评论 收藏
分享
10-17 23:18
已编辑
西北农林科技大学 Web前端
独行m:给25可以试试,但他只能给12,那就是纯纯的事精
秋招,不懂就问
点赞 评论 收藏
分享
头像
10-27 15:50
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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