求两个list的差集(去重),python set应用
1 #2215
2 #Runtime: 142 ms (Beats 72.81%)
3 #Memory: 13.7 MB (Beats 71.49%)
4
5 class Solution(object):
6 def findDifference(self, nums1, nums2):
7 """
8 :type nums1: List[int]
9 :type nums2: List[int]
10 :rtype: List[List[int]]
11 """
12 s1 = set(nums1)
13 s2 = set(nums2)
14 return [list(s1 - s2), list(s2 - s1)]