Most Frequent Letter
InterviewTime limit2sMemory limit128 MB
Count letter frequencies in a string, case-insensitively, and print the most common letter in uppercase or a question mark on ties.
- Level
Easy2 of 10
- Topics
- Hash map, String, Implementation
- Solved
- No attempts yet
Problem
Given a word made of uppercase and lowercase English letters, determine which alphabet letter appears most often. Uppercase and lowercase versions of the same letter are treated as the same letter.
Input
The first line contains a word made of uppercase and lowercase English letters. The length of the word is at most 1,000,000.
Output
Print the most frequent letter in uppercase on the first line. If two or more letters are tied for the highest frequency, print ?.