题目[1,2,2,1] ,[2,2] return [2,2]思路hash表代码def common_str(list1,list2): hash1 = {} for i in list1: hash1[i] = 1 + hash1.get(i,0) list = [] for j in list2: if j in hash1 and hash1[j]>0: list.append(j) hash1[j] -= 1 return
hash表
2023-09-17
36 点赞
0 评论
54 浏览