Find the letter that appears most frequently in a word, ignoring case, and report whether it is unique.
Sleuth
You are given a word consisting of English letters. Treat uppercase and lowercase versions of the same letter as identical.
Your task is to determine which letter appears most often in the word.
- If exactly one letter has the highest frequency, output that letter in uppercase.
- If more than one letter is tied for the highest frequency, output
?.
This is a simple string-processing problem focused on counting characters.
Input Format
- A single line containing one non-empty word.
- The word contains only English letters
A-Zanda-z.
Output Format
- Print a single character:
- the uppercase letter with the highest frequency, or
?if the maximum frequency is not unique.
Constraints
- The input word length is small enough for a linear scan.
- Letters are case-insensitive.
- Only alphabetic characters appear in the input.
Example 1
Input
Mississipi
Output
?
Explanation
After ignoring case, i and s both occur 4 times, so the answer is not unique.
Example 2
Input
zZa
Output
Z
Explanation
z appears twice and a appears once, so the most frequent letter is Z.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.