N-Repeated Element in Size 2N Array LeetCode solution in C++

1
class Solution {
2
public:
3
int repeatedNTimes(vector<int> &nums) {
4
unordered_map<int, int> mp;
5
for (auto it : nums) mp[it]++;
6
int n;
7
for (auto it : mp) {
8
if (it.second == nums.size() / 2) {
9
n = it.first;
10
break;
11
}
12
}
13
return n;
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0