sy1214ei 님의 블로그

[Leet Code] 349. Intersection of Two Array 본문

[Coding]

[Leet Code] 349. Intersection of Two Array

sy1214ei 2024. 11. 25. 00:32
class Solution:
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        arr = []
        nums1 = set(nums1); nums2 = set(nums2)

        for num in nums1:
            if num in nums2:
                arr.append(num)
        return arr

'[Coding]' 카테고리의 다른 글

[Leet Code] 414. Third Maximum Number  (1) 2024.11.25
[Leet Code] 350. Intersection of Two Arrays II  (0) 2024.11.25
[Leet Code] 217. Con tains Duplicate  (3) 2024.11.25
[Leet Code] 56. Merge Intervals  (0) 2024.11.24
[Leet Code] 179. Largest Number  (0) 2024.11.24