Find the Difference of Two Arrays LeetCode solution in Python

1
# Runtime: 953 ms (Top 29.31%) | Memory: 14.3 MB (Top 52.22%)
2
class Solution(object):
3
def findDifference(self, nums1, nums2):
4
"""
5
:type nums1: List[int]
6
:type nums2: List[int]
7
:rtype: List[List[int]]
8
"""
9
a = []
10
for i in range(len(nums1)):
11
if nums1[i] not in nums2:
12
a.append(nums1[i])
13
b = []
14
for i in range(len(nums2)):
15
if nums2[i] not in nums1:
16
b.append(nums2[i])
17

18
c = [list(set(a))] + [list(set(b))]
19

20
return c

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0