You are viewing a single comment's thread. Return to all comments →
Few test cases are failed, what's wrong in below code?
from collections import defaultdict n,m=map(int, input().split()) groupA=[] groupB=[] for _ in range(n): groupA.append(input().strip()) for _ in range(m): groupB.append(input().strip()) output=defaultdict(list) for i,value in enumerate(groupA,1):
for j in groupB: if value==j: output[value].append(i) elif value not in groupB: output[value].append(-1)
for o in output: print(*output[o])
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 →
Few test cases are failed, what's wrong in below code?
for o in output: print(*output[o])