fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <map>
  4. using namespace std;
  5.  
  6. int main() {
  7. const initializer_list<int> a[] = {{5, 7, 8}, {6, 6}, {}, {5, 6, 8, 9}};
  8. map<int, int> totals;
  9.  
  10. for(const auto& i : a) for_each(cbegin(i), cend(i), [&](const auto& it){ totals[it]++;});
  11.  
  12. cout << max_element(cbegin(totals), cend(totals), [](const auto& lhs, const auto& rhs){return lhs.second < rhs.second;})->first << endl;
  13. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
6