题解 | #查找#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
//采用map容器的做法
#include "stdio.h"
#include "map"
using namespace std;
int main(){
map<int,int> findNum;
int n,m;
int arr[100];
int Num;
while (scanf("%d",&n)!=EOF){
for (int i = 0; i < n; ++i) {
scanf("%d",arr+i);
findNum[arr[i]]=i;
}
scanf("%d",&m);
for (int i = 0; i < m; ++i) {
scanf("%d",&Num);
if(findNum.find(Num)==findNum.end())
printf("NO\n");
else
printf("YES\n");
}
}
}