leetcode——350.两个数组的交集2

class Solution:
    def intersect(self, nums1, nums2):
        l1=len(nums1)
        l2=len(nums2)
        num=[]
        if l1>l2:
            for i in nums2:
                if i in nums1:
                    num.append(i)
                    nums1.remove(i)
        else:
            for i in nums1:
                if i in nums2:
                    num.append(i)
                    nums2.remove(i)
        return num
执行用时 :92 ms, 在所有 Python3 提交中击败了45.21%的用户
内存消耗 :13.9 MB, 在所有 Python3 提交中击败了5.06%的用户
 
                                               ——2019.10.7
我的前方是万里征途,星辰大海!!
原文地址:https://www.cnblogs.com/taoyuxin/p/11631006.html