leetcode 349. Intersection of Two Arrayspython

    xiaoxiao2021-03-25  55

    Given two arrays, write a function to compute their intersection.

    Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].

    class Solution(object):     def intersection(self, nums1, nums2):         """         :type nums1: List[int]         :type nums2: List[int]         :rtype: List[int]         """         n1 = set(nums1)         n2 = set(nums2)         n3 = n1 & n2         return list(n3)
    转载请注明原文地址: https://ju.6miu.com/read-36807.html

    最新回复(0)