题解 | #查找#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include<cstdio> #include<map> #include<algorithm> using namespace std; int main() { map< int, int >findindx; int m, n ; int arr[200]; while (scanf("%d", &n) != EOF) { for (int i = 0 ; i < n ; ++ i) { scanf("%d", &arr[i]); findindx[arr[i]] = i ; } scanf("%d", &m); for (int i = 0 ; i < m ; ++ i ) { int x; scanf("%d", &x); // if (findindx.find(x) == findindx.end()) { printf("NO\n"); } else { printf("YES\n"); } } } }