We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22a90c0 commit eff603dCopy full SHA for eff603d
MaxOccuringString.cpp
@@ -0,0 +1,32 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+#define ll long long
4
+
5
6
+int main()
7
+{
8
+ string str;
9
+ cout << "Enter String: ";
10
+ cin >> str;
11
12
+ unordered_map<char, int> maxChar;
13
14
+ for (int i = 0; i < str.size();i++)
15
+ {
16
+ if(maxChar.find(str[i]) != maxChar.end())
17
+ maxChar[str[i]]++;
18
+ else
19
20
+ }
21
22
+ char ch=maxChar.begin()->first;
23
+ for (auto i = maxChar.begin(); i != maxChar.end(); i++)
24
25
+ if(maxChar[ch]<i->second)
26
+ ch = i->first;
27
+ cout << i->first<<" "<<i->second<<endl;
28
29
30
+ cout << "\nMaximum occured character in the string : " << ch << " " << maxChar[ch];
31
+ return 0;
32
+}
0 commit comments