forked from rahulraghavendhra/HackerRank-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popular_characters.py
49 lines (47 loc) · 1.84 KB
/
popular_characters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Pǿpųłǻř Čħǻřǻčțěřș (Čǿđıňģ)
Ỳǿų ħǻvě ǻ łıșț ǿf șțřıňģș, ěǻčħ ǿf ẅħıčħ ıș čǿmpǿșěđ ǿf łǿẅěřčǻșě łěțțěřș
fřǿm 'ǻ' țǿ 'ž'. Ǻ "pǿpųłǻř" čħǻřǻčțěř ıș đěfıňěđ țǿ bě ǿňě ẅħıčħ ǻppěǻřș ıň
ǻłł țħě șțřıňģș.
Ģıvěň ǻ łıșț ǿf șțřıňģș, čǿųňț țħě ňųmběř ǿf pǿpųłǻř čħǻřǻčțěřș.
İňpųț Fǿřmǻț
Țħě fıřșț łıňě čǿňșıșțș ǿf Ň, țħě ňųmběř ǿf șțřıňģș.
Țħě ňěxț Ň łıňěș ǻřě țħě Ň șțřıňģș (čǿmpǿșěđ ǿf łǿẅěřčǻșě łěțțěřș fřǿm 'ǻ'
țǿ 'ž').
Ǿųțpųț Fǿřmǻț
Přıňț țħě ňųmběř ǿf pǿpųłǻř čħǻřǻčțěřș ıň țħě șțřıňģș. İf țħěřě ǻřě ňǿňě,
přıňț 0.
Čǿňșțřǻıňțș
1 ≤ Ň ≤ 100
Ěǻčħ șțřıňģ čǿňșıșțș ǿf ǿňłỳ șmǻłł łǻțıň łěțțěřș ('ǻ'-'ž').
1 ≤ Łěňģțħ ǿf ěǻčħ șțřıňģ ≤ 100
Șǻmpłě İňpųț
3
abcdde
baccd
eeabg
Șǻmpłě Ǿųțpųț
2
Ěxpłǻňǻțıǿň
Țħě ǿňłỳ pǿpųłǻř čħǻřǻčțěřș ǻřě 'ǻ' ǻňđ 'b', șıňčě țħěșě ǻřě țħě ǿňłỳ
čħǻřǻčțěřș țħǻț ǻppěǻř ıň ěvěřỳ șțřıňģ.
"""
main_dict = {}
count = 0
if __name__ == '__main__':
n = input()
for i in range(n):
input_string = raw_input()
str_array = set(input_string)
for char in str_array:
if char in main_dict:
main_dict[char] = main_dict[char] + 1
else:
main_dict[char] = 1
for element in main_dict:
if main_dict[element] == int(n):
count = count + 1
if count == 0:
print "No Common characters in the string"
else:
print count