6.两个数组的交集 II(Python)

版权声明:@author:geek_aaron https://blog.csdn.net/weixin_39433783/article/details/83000174

在这里插入图片描述参考代码

class Solution:
    def intersect(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[int]
        """
        res = []
        for i in nums1:
        	if i in nums2:
        		res.append(i)
        		nums2.remove(i)
        return res

猜你喜欢

转载自blog.csdn.net/weixin_39433783/article/details/83000174