Maximum Occuring Character
Basic Accuracy: 50.0% Submissions: 21224 Points: 1

Given a string str. The task is to find the maximum occurring character in the string str. If more than one character occurs the maximum number of time then print the lexicographically smaller character.

Example 1:

str = testsample
Output: e
Explanation: e is the character which
is having the highest frequency.

Example 2:

str = output
Output: t
Explanation:  t and u are the characters
with the same frequency, but t is
lexicographically smaller.

Your Task:
The task is to complete the function getMaxOccuringChar() which returns the character which is most occurring.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Number of distinct characters).
Note: N = |s|

1 ≤ |s| ≤ 100

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Maximum Occuring Character

Output Window