题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768
感觉map太强了,完全可以代替哈希表,之前哈希表那块写的什么玩意。。
代码
#include<map>#include<vector>#include<algorithm>#include<iostream>using namespace std;map<int, int> arr;int main(){int m, n, temp;int ans, max = -1;scanf("%d%d", &m, &n);for(int i = 0; i < m; i++){for(int j = 0; j < n; j ++){scanf("%d",&temp);if(arr.find(temp)==arr.end()){arr[temp] = 0;} else {arr[temp]++;}if(arr[temp] > max) ans = temp;}}printf("%d",ans);}
