fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int arr[] = { 1, 3, 876, 22, 456, 1, 456, 18, 34546, 1};
  10.  
  11. map<int,int> m;
  12. for(auto i: arr) m[i]++;
  13. auto it = max_element(m.begin(),m.end(),[](auto a, auto b) { return a.second < b.second; });
  14.  
  15. cout << it->first;
  16.  
  17. }
  18.  
Success #stdin #stdout 0s 4500KB
stdin
Standard input is empty
stdout
1