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
|
1027 Discussions
|
Please Login in order to post a comment
A possible solutions fellers:
Few test cases are failed, what's wrong in below code?
for o in output: print(*output[o])
test 1 ,2 and 5 did not pass please help.
from collections import defaultdict size_of_groups = input().split(' ') A=[] result= defaultdict(list) for i in range(int(size_of_groups[0])): A.append(input()) for i in range(int(size_of_groups[1])): x=input() if x not in A : result[x].append(-1) while x in A : result[x].append(A.index(x)+1) A[A.index(x)]= 0
for i in result.values(): print(' '.join(str(x) for x in i))
test cases 1,2,3,4 not satisfied mates. pls debug this
n,m = [int(i) for i in input().split()] A = [] B = [] for i in range(n): A.append(input()) for i in range(m): B.append(input())
for i in B: c=0 for j in range(1,len(A)+1): if A[j-1] == i: print(j,end=' ') c=1 if c==0: print(-1) print('')