def solve(self, A, B):
A = set(A.split("_"))
ans = []
for i,v in enumerate(B):
temp = 0
for w in v.split("_"):
if w in A:
temp+=1
ans.append((temp,i))
return [v for i,v in sorted(ans,key = lambda x:(-x[0],x[1]))]
Python is Love (Very easy and concise)
algo-compute
#1