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.
fromcollectionsimportdefaultdictn,m=input().split()result=defaultdict(list)forindex,_inenumerate(range(int(n)),1):val=input()# result[val] = result[val].append(index) if val in result else [index]result[val].append(index)for_inrange(int(m)):b_val=input()ifb_valinresult:print(*result[b_val])else:print(-1)
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 →
Here is my code