File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
/*given N string, print unique sting
6+
in Lexicpgraphical order with their frequency
7+
8+
*/
9+
10+
// map uses red black self balencing tree in backend and it always stored keys in sorted manner
11+
int main ()
12+
{
13+
map<string , int >m; // key as string and value as integer
14+
int n;
15+
cin>>n;
16+
for (int i=0;i<n;++i)
17+
{
18+
string s;
19+
cin>>s;
20+
/*m[s]=m[s]+1; or we can write m[s]++ both are same */
21+
m[s]++;
22+
}
23+
for (auto pr : m)
24+
{
25+
cout <<pr.first<<" "<< pr.second <<" " <<endl;
26+
}
27+
28+
}
29+
//

0 commit comments

Comments
 (0)