使用哈希表进行记录
#include<iostream>
#include<unordered_map> // 使用哈希表
using namespace std;
int n;
int main()
{
unordered_map<int, int> a; //创建哈希表
cin >> n;
int max1 = 0;
while(n --)
{
int x;
cin >> x;
a[x] ++; // 每次让选到的数 += 1
max1 = max(max1, a[x]); // 更新答案
}
cout << max1 << endl;
return 0;
}