Maximum Occuring Character
Basic Accuracy: 43.68% Submissions: 8886 Points: 1

Given a string str. The task is to find the maximum occurring character in the string str. If more than one character occurs maximum number of time then print the lexicographically smaller character.

Input:
The first line of input contains an integer T denoting the number of test cases. Each test case consist of a string in 'lowercase' only in a separate line.

Output:
For each testcase, in a new line, print the lexicographically smaller character which occurred the maximum time.

Constraints:
1 ≤ T ≤ 30

1 ≤ |s| ≤ 100

Example:
Input:

2
testsample
output

Output:
e
t

Explanation:
Testcase 1:
e is the character which is having highest frequency.
Testcase 2: t and u are the characters with the same frequency, but t is lexicographically smaller.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window