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.
- Prepare
- Python
- Collections
- DefaultDict Tutorial
- Discussions
DefaultDict Tutorial
DefaultDict Tutorial
Sort by
recency
|
1125 Discussions
|
Please Login in order to post a comment
from collections import defaultdict
n, m = map(int, input().split())
groupA = defaultdict(list) for i in range(1, n + 1): word = input().strip() groupA[word].append(i)
groupB = [input().strip() for _ in range(m)]
for word in groupB: if word in groupA: print(*groupA[word]) else: print(-1)
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)
This code passes half the test cases but fails the other half. Any ideas on why?