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.
# my solution uses enumerate() to create the list of indices to be printed. If a word/letter is not found in group A, minus one is printed instead.fromcollectionsimportdefaultdictd=defaultdict(list)n,m=input().split()foriinrange(int(n)):d["A"].append(input())forjinrange(int(m)):d["B"].append(input())forletterind["B"]:ifletterind["A"]:b_list=[str(i+1)fori,xinenumerate(d["A"])ifx==letter]print(" ".join(b_list))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 →