#C80. Most Popular Programming Language
Most Popular Programming Language
Most Popular Programming Language
You are given a survey of programming language preferences. Each survey response is a string representing the name of a programming language. Your task is to identify the language that appears the most frequently. In the event of a tie, return the language which is alphabetically smallest.
For example, if the responses are "Python", "Java", "Python", "C++", "Java", "Python", then the answer is "Python" because it appears 3 times, which is more than any other language. And if the responses are "Go", "Rust", "Go", "Rust", both appear twice, so the answer is "Go" since 'G' comes before 'R' in alphabetical order.
Input/Output Format:
- The input is read from standard input (stdin).
- The first line contains an integer N, the number of responses.
- The following N lines each contain one string (the name of a programming language).
- The output should be written to standard output (stdout) as a single string representing the most popular programming language.
Note: In the case of a tie where multiple languages have the highest frequency, choose the language that comes first in lexicographical order. That is, if LaTeX were used to represent conditions, you could write the tie-break condition as: $$\min\{\text{languages}\,|\,\text{frequency} = \max\{\text{frequency}\}\}.$$
inputFormat
The input begins with an integer N denoting the number of responses. Following this, there are N lines where each line contains a programming language name.
Example:
6 Python Java Python C++ Java Python
outputFormat
Output a single line containing the most popular programming language. In the event of a tie, output the language which is lexicographically smallest.
Example:
Python## sample
1
Python
Python