首页 > 代码库 > 【leetcode?python】Intersection of Two Arrays

【leetcode?python】Intersection of Two Arrays

#-*- coding: UTF-8 -*-
#求两个集合的交集
class Solution(object):
    def intersection(self, nums1, nums2):
       resultList=list(set(nums1).intersection(set(nums2)))
       return resultList

sol=Solution()
print sol.intersection(nums1=[1, 2, 2, 1], nums2=[2,2])

【leetcode?python】Intersection of Two Arrays