traversing a map c++ code example
Example: Traversing a map
int arr[] = { 1, 1, 2, 1, 3, 1, 4, 3 };
map<int, int> m;
for (auto i: arr)
m[arr[i]]++;
cout << "Element Frequency" << endl;
for (auto& [k,v] : m) // Since c++17
cout << k << " " << v << endl;