P19929 [GeeksforGeeks] Maximum occuring character 1587115620
普及-
题目描述

Given a string str of lowercase alphabets. 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:
Input:
str = testsample
Output: e
Explanation: e is the character which
is having the highest frequency.
Example 2:
Input:
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|
Constraints:
1 ≤ |s| ≤ 100

输入格式

见题面

输出格式

见题面

样例输入
str = testsample
样例输出
e