Problem:https://www.hackerrank.com/challenges/sparse-arrays/problem

Sample Code:


from collections import Counter
s=list()
q=list()
for _ in range(int(input())):
    s.append(input())
for _ in range(int(input())):
    q.append(input())    
dct=Counter(s)    
for str in q:
    print(dct.get(str) if str in dct else 0)

Explanation:

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top