Home Intersection of Two Arrays
Post
Cancel

Intersection of Two Arrays

Leetcode Problem

Intersection of Two Arrays

nums1, nums2 배열이 주어졌을 때, 두 배열의 교집합을 구하는 문제입니다.

1
2
3
class Solution:
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        return list(set(nums1).intersection(set(nums2)))

set 자료형으로 간단히 해결할 수 있습니다.





참고

This post is licensed under CC BY 4.0 by the author.