没看答案。
考察了取两个字典的交集操作。
from collections import Counter
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
a = Counter(nums1)
b = Counter(nums2)
res = []
c = a & b
for num in c:
count = c[num]
while count:
res.append(num)
count -= 1
return res