题解 | #判断元素是否出现#
判断元素是否出现
https://www.nowcoder.com/practice/0787459e92bc4360ba48b094b7f21577
#include<bits/stdc++.h> #include <map> using namespace std; int main(){ //write your code here...... int n, m, a, x; cin >> n; cin >> m; map<int , int> mp; for (int i = 0; i < n; i++) { cin >> a; mp[a] = a; } for (int i = 0; i < m; i++) { cin >> x; auto it = mp.find(x); if (it != mp.end()) cout << "yes" << endl; else cout << "no" << endl; } return 0; }