fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s="geeksforgeeks";
  7. unordered_map<char,int>arr;
  8. for(char i:s){
  9. arr[i]++;
  10. }
  11. for(auto a:arr){
  12. if(a.second>1){
  13. cout<<"["<<a.first<<" "<<a.second<<"]"<<endl;
  14. }
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
[e 4]
[g 2]
[k 2]
[s 2]