Skip to content

Commit 3cca5a7

Browse files
authored
Create find-common-elements-between-two-arrays.py
1 parent e71e8df commit 3cca5a7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(n + m)
2+
# Space: O(n + m)
3+
4+
# hash table
5+
class Solution(object):
6+
def findIntersectionValues(self, nums1, nums2):
7+
"""
8+
:type nums1: List[int]
9+
:type nums2: List[int]
10+
:rtype: List[int]
11+
"""
12+
lookup1, lookup2 = set(nums1), set(nums2)
13+
return [sum(x in lookup2 for x in nums1), sum(x in lookup1 for x in nums2)]

0 commit comments

Comments
 (0)