Question
First Maximum Occurring Character
You are given a string s consisting of lowercase English letters.
Your task is to find the character that appears the maximum number of times in the string.
If multiple characters have the same maximum frequency, print the character that appears first in the string.
| Hint |
| Can set or dictionary be used in this problem? |
Input
A single line containing a string s
Output
Print the character with the highest frequency in the string. If multiple characters have the same maximum frequency, print the character that appears first in the string.
Example
Example 1
Input:
banana
Output:
a
Explanation
a appears 3 times, which is the highest frequency.
Example 2
Input:
bbacac
Output:
b
Explanation:
All characters appear twice.
b appears first in the string, so it is printed.
Input:
banana
Output:
a
Explanation
a appears 3 times, which is the highest frequency.
Example 2
Input:
bbacac
Output:
b
Explanation:
All characters appear twice.
b appears first in the string, so it is printed.