#include <bits/stdc++.h> using namespace std; int main() { string s="geeksforgeeks"; unordered_map<char,int>mp; for(auto x:s) { mp[x]++; } for(auto x:mp) { cout<<x.first<<", "<<"count"<<"["<<x.second<<"]"<<"\n"; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter