题解 | #找出重复的数字#C++遍历哈希表解法
找出重复的数字
https://www.nowcoder.com/practice/1664fe871878496aa600b6e09557982b
#include <iostream> #include <vector> #include <unordered_map> using namespace std; int main() { int i=0; unordered_map<int,int> hash; while(cin>>i) { if(hash.count(i)==0) { hash[i]=1; } else { hash[i]++; if(hash[i]==2) { cout<<i; } } } return 0; }