Given two arrays, write a function to compute their intersection.
Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].
Note:
- Each element in the result must be unique.
- The result can be in any order.
Subscribe to see which companies asked this question
class Solution(object):
def intersection(self, nums1, nums2):
s1 = set(nums1)
s2 = set(nums2)
return list(s1 & s2)

225

被折叠的 条评论
为什么被折叠?



