题解 | #数组中重复的数字#
数组中重复的数字
https://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
#include <unordered_map> class Solution { public: int duplicate(vector<int>& numbers) { unordered_map<int, int> mp; for(int i=0;i<numbers.size();i++) { if(mp.count(numbers[i])) { return numbers[i]; } else { mp[numbers[i]]++; } } return -1; } };