forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path67-2.py
More file actions
15 lines (12 loc) · 439 Bytes
/
67-2.py
File metadata and controls
15 lines (12 loc) · 439 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import bisect
from typing import List, Set
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
result: Set = set()
nums2.sort()
for n1 in nums1:
# 이진 검색으로 일치 여부 판별
i2 = bisect.bisect_left(nums2, n1)
if len(nums2) > 0 and len(nums2) > i2 and n1 == nums2[i2]:
result.add(n1)
return result