Common Alphabets N Strings
Common Alphabets N Strings:
Problem:
N string values are passed as input to the program. Each string will contain only the alphabets a-z in lower case. A given alphabet may be repeated any number of times. The program must print the count C of the alphabets that are present in all the N string values.
Input Format:
The first line contains N. Next N lines contain the N string values.
Output Format:
The first line contains C.
Boundary Conditions:
2 <= N <= 500
1 <= Length of the string value <= 1000
Example Input/Output 1:
Input:
3
mnppqqr
ajkmnnm
poormanagement
Output:
2
Explanation:
Only 2 alphabets m and n are present in all the three string values.
Program:
n = int(input())
d = dict()
for i in range(n):
s = set(input().strip())
for j in s:
try:
d[j] += 1
except:
d[j] = 1
c = 0
for i in d:
if d[i] == n :
c += 1
print(c)
Comments
Post a Comment