Problem Statement
Jackson is a frequent flyer and has been to many places around the world!
Jackson has a list of destinations he has flown to in the past. He wants to know which place he has flown to the most!
You are given a list of flight destinations you have been to in the past, output the most frequent place you have flown to.
Input
Your first line of input will contain a single integer : the number of destinations flown to in total. Next, lines will follow, each containing a single string : the name of a destination each.
Output
A single line, containing the name of the most frequent place Jackson has flown to.
If there is a tie, choose the place with the lexicographically (alphabetically) smallest name.
Constraints
- Each only contains English lower-case alphabet letters.
Example 1
Input
10
japan
hongkong
japan
hongkong
france
germany
france
germany
japan
japan
Output
japan
Explanation
Japan appeared more than any other location.
Example 2
Input
4
asia
asia
antarctica
antarctica
Output
antarctica
Explanation
There are places with the same number of flights flown to them.
Antartica is the alphabetically smaller destination, so it should be the final output over everything else.
Template
n = int(input())
f = [input() for _ in range(n)]
# Continue your code here and print your final answer!
Solution
If you'd like to view a sample solution to this tutorial question, please click the "Read Editorial" link to the right of the problem!
Comments