Tournament
Practice
4 (4 votes)
Hash table
Hashmap
Basic programming
Easy
Open
Approved
Problem
87% Success 2035 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Lord Paul of the Seven Kingdoms has organized a fighting tournament between all the warriors of the kingdom. He finally gets the match summary of the entire tournament, which states which warrior fought with which warrior. Lord Paul wants you to find out the number of warriors who participated in maximum number of matches. (Which means they survived these many matches!) If there are warriors with equal number of matches, print all of them in lexicographical order (sorted order).

Input:

First line of input contains number of matches N.
Next N lines contains two names of worriers who fought with each other.

Output:

Print number of worriers who participated in maximum numbers of matches. If there are warriors with equal number of matches, print all of them in lexicographical order (sorted order).

Constraints:

1 ≤ N ≤ 105
1 ≤ |length of team name| ≤ 20

Note:

All team names will be in Uppercase only.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
9 votes
Tags:
Hash functionAd-HocImplementationHash tableOpenApprovedEasy
Points:20
9 votes
Tags:
OpenApprovedHashingEasy
Points:20
5 votes
Tags:
Hash functionBasic ProgrammingString-ManipulationHash tableBasic-ProgrammingOpenApprovedEasy