Special Words

0

0 votes
Problem

Special word is a word which starts with a '#' . You are given a list of statements and your task is to find the top 5 most occuring 'special words' in the given list. Each statement , let's call it S, will contain at least one special word. There will be maximum of three special words in any statement. All special words in a single statement will be unique.

Input:
First line of the input will contain N denoting the number of statements.
Next N lines, each will contain a string S.

Output:
Print the top five most occuring special words. In case of tie between any two special words, print them in lexicographical order in a new line.

Constraints: 

  • 10N103
  • 1|S|140 where |S| denotes length of string S i.e. length of statement.
  • Any special word is denoted by H  1|H|20 where |H| denotes length of special word H.

Note:

  • Any statement is composed of lowercase and uppercase English letters, digits and spaces.
  • Any speacial word begins with # and the subsequent characters will only contain lowercase and uppercase English letters and digits.

 

Sample Input
10
Donald Trump becomes the 45th #US President
Potentially habitable exoplanet #ProximaB discovered
#RogerFederer wins #US Open for 5th time
#GravitationalWaves detection successful
Traces of liquid water discovered on #Mars
Life Could Survive on Exoplanet #ProximaB
Go go #RogerFederer
Ten ways #ProximaB is different from Earth
ISRO becomes 4th space agency to reach #Mars
#RogerFederer beats #Nadal
Sample Output
#ProximaB
#RogerFederer
#Mars
#US
#GravitationalWaves
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?