-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
python解得,简单,没啥可说的
class Solution:
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
record, result = {}, []
for num in nums1:
record[num] = record.get(num, 0) + 1
for num in nums2:
if num in record and record[num]:
result.append(num)
record[num] -= 1
return result