Building a Frequency Table Before Charting
Calder Sixth Form hands Ashgrove Analytics this year's letter grades, one per student, in the order the marking finished. Letters have no numeric size, so there is nothing to band automatically — the tally has to be built first and drawn as one bar per letter. The head of year wants the headline written underneath: which grade came up most often.
Task: Print the single grade that appears most often. If two or more grades tie for most common, print whichever of them appeared earliest in the list as it was handed over. That is the tie-break — not the alphabetically first letter.
Input
The first line holds an integer n, the number of students. Each of the next n lines holds one grade: a single capital letter, one of A, B, C, D or F. n is at least 1.
Output
One line holding a single capital letter.
Example:
Input:
5
A
B
B
C
B
Output:
B
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in