➤ Problem Link : SBANK
👉 Hint : Use hashing and sorting together(Map in C++)
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
map<string,int> m;
while(t--)
{
string s;
m.clear();
int n;
cin>>n;
cin.ignore();
for(int i=0;i<n;i++)
{
getline(cin,s);
m[s]++;
}
for(auto it=m.begin();it!=m.end();it++)
cout<<(*it).first<<" "<<(*it).second<<endl;
cout<<endl;
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
