We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if name == 'main':
N = list(map(int, input().split()))
d = defaultdict(list)
for i in range(N[0]):
letter = input()
d[letter].append(int(i+1))
#print(d)
for i in range(N[1]):
letter = input()
if letter in d.keys():
print(*d[letter])
else:
print(-1)
purchase_order(arr, sizes)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →
from collections import defaultdict
if name == 'main':
N = list(map(int, input().split())) d = defaultdict(list) for i in range(N[0]): letter = input() d[letter].append(int(i+1)) #print(d)
purchase_order(arr, sizes)