Skip to main content
Back to problems
Codeforces
Easy
Strings
Hash Maps
Sleuth

Find the letter that appears most frequently in a word, ignoring case, and report whether it is unique.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

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-Z and a-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.
Examples
Sample cases returned by the problem API.

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.