Back to problems

Most Frequent Character with Lexicographical Tie-Breaking

Algorithm · Squarepoint · Easy

You are given a non‑empty string s of lowercase English letters. Count the occurrences of each character and find the one with the highest frequency. If two or more characters share the maximum count, return the lexicographically smallest (for instance, 'a' beats 'b'). Input Format A single line containing the string s (lowercase letters only). Output Format Print the character that meets the criteria. Constraints 1 <= len(s) <= 10^5 Example Input: Output: Explanation: The…

Checking your access…