You are viewing a single comment's thread. Return to all comments →
I fail to see the utility of defaultdicts for this problem. List comprehensions provide, IMO, more readable code:
n, m = [int(x.strip()) for x in input().split()] a = [input().strip() for _ in range(n)] b = [input().strip() for _ in range(m)] for w in b: indices = [i+1 for i, x in enumerate(a) if x == w] if indices: print(*indices) else: print(-1)
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 →
I fail to see the utility of defaultdicts for this problem. List comprehensions provide, IMO, more readable code: