Only One String Alphabets

 Coding Problem Keys 

 Only One String Alphabets 

 Problem Statement 

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 only in one string value.

 Boundary Condition(s) 

2 <= N <= 500
1 <= Length of string value <= 1000

 Input Format 

The first line contains N.
Next N lines contains the N string values.

 Output Format 

The first line contains Count C.

 Example Input/Output 1 

 Input 

3
mnppqqr
ajkmnnm
poormanagement

 Output 

7

 Explanation 

qtegjko are the 7 characters that are present only in one string value.
q is present only in 1st string
j & k are present only in 2nd string
t e g o are present only in 3rd string

 Note: Max Execution Time Limit: 5000 millisecs 

 Solution 

 Programming Language: Python 3 Language 

n=int(input())
l=[input().strip() for i in range(n)]
unique=[];duplicate=[]
for i in l:
    s=[]
    for j in i:
        if j in duplicate and j in unique:
            unique.remove(j)
        elif j in duplicate:
            continue
        elif j not in unique:
            unique.append(j)
            s.append(j)
    duplicate.extend(s)
print(len(unique))

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Highly Profitable Months

Flowchart Logic 047

Desktop Products

Find Maxima/Minima

Matrix Print Excluding Border Elements

Words Starting with Upper Case

Occurrences of Sub in Parent