You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
671 B

#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
int main() {
int n;
cin >> n;
//用数据结构unordered_map
unordered_map<int, int> _map;
int c;
for (int i = 0; i < n; i++) {
cin >> c;
_map[c]++;
}
//对value进行排序,tmp为结果(经典用法,板子)
vector<pair<int, int>> tmp;
for (auto &i : _map)
tmp.push_back(i);
sort(tmp.begin(), tmp.end(),
[=](pair<int, int> &a, pair<int, int> &b) { return a.second < b.second; });
//输出最后一个元素的first即可
cout << tmp[tmp.size() - 1].first << endl;
return 0;
}