Skip to content

Commit 9ca78ad

Browse files
authored
Create find-the-difference-of-two-arrays.py
1 parent 52e10ff commit 9ca78ad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
# hash table
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+
lookup = [set(nums1), set(nums2)]
13+
return [list(lookup[0]-lookup[1]), list(lookup[1]-lookup[0])]

0 commit comments

Comments
 (0)