#K38737. Highest Frequency Character
Highest Frequency Character
Highest Frequency Character
You are given a string s
. Your task is to find the character that appears the most in s
. If there is a tie for the highest frequency, output the character that appears first in s
.
If the string is empty, output None
.
Note: The input string may contain letters, digits, or special characters. You should consider all characters.
Example: For s = "aabbbcc"
, the answer is b
, because although both 'a' and 'b' appear frequently, 'b' reaches the maximum count earlier in the string when considering the tie-breaking rule.
inputFormat
The input consists of a single line containing the string s
.
outputFormat
Output the character with the highest frequency based on the conditions described. If the string is empty, output None
.
aabbbcc
b