#C8054. Most Frequent Character
Most Frequent Character
Most Frequent Character
Given a string s, your task is to find the character that appears most frequently in s. In case of a tie, return the lexicographically smallest character. Formally, if we define the frequency function \(f(c)\) as the number of times character \(c\) appears in s and let \(M = \max\{f(c): c \in s\}\), then your answer should be:
[ \min{c \mid f(c)=M} ]
You are given multiple test cases. For each test case, output the answer on a separate line.
inputFormat
The first line of input contains an integer T
, representing the number of queries.
Each of the following T
lines contains a single string s
.
outputFormat
For each query, output the most frequent character in s
on a separate line.
1
abracadabra
a
</p>