题解 | #查找#

查找

https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa

#include <iostream>
#include <map>
using namespace std;

int main() {
    int n,m;
    cin>>n;
    map<int,bool> mp;
    while(n--){
        int temp;
        cin>>temp;
        mp[temp]=true;
    }
    cin>>m;
    while(m--){
        int temp;
        cin>>temp;
        if(mp.find(temp)!=mp.end()) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

04-25 18:13
五邑大学 Java
无面如何呢:用心包装一下自己的实习
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务