Most Common Survey Rating
Whetcode shipped a redesigned checkout screen and put a one-question survey behind it: rate the new flow from 1 (hated it) to 5 (loved it). The product manager is writing the release note and wants to finish the sentence "most users rated it …" — which means the number has to be a rating a human could actually have picked, not something that lands between two of them. The same line is rerun for every screen the team ships, and the responses never look the same twice.
Task: Print the most common rating — the mode — as a single integer. In every batch exactly one rating occurs more often than every other, so there is no tie to break.
Input
The first line holds one integer n, the number of responses (at least 1). The second line holds the n ratings, whole numbers from 1 to 5, separated by spaces.
Output
One line holding the most common rating as a plain integer.
Example:
Input:
9
3 4 4 5 2 4 5 4 3
Output:
4
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