分析:
本来刷二分的,但是这道题不用双指针也能做
所以就偷个懒,加上数组范围小,遍历就行
代码:
1 class Solution(object): 2 def intersection(self, nums1, nums2): 3 """ 4 :type nums1: List[int] 5 :type nums2: List[int] 6 :rtype: List[int] 7 """ 8 count=[] 9 if len(nums1)<len(nums2): 10 for i in nums1: 11 if i in nums2 and i not in count: 12 count.append(i) 13 elif len(nums1)>len(nums2): 14 for i in nums2: 15 if i in nums1 and i not in count: 16 count.append(i) 17 else: 18 for i in nums1: 19 if i in nums2 and i not in count: 20 count.append(i) 21 return count
标签:count,交集,List,nums1,int,数组,349,nums2 From: https://www.cnblogs.com/ooooopppp/p/17374262.html