My Python Solution


  • 0
    L
    class Solution(object):
        def intersection(self, nums1, nums2):
            """
            :type nums1: List[int]
            :type nums2: List[int]
            :rtype: List[int]
            """
            intersection_list = []
            if len(nums2) < len(nums1):
                for each_nums1 in nums1:
                    if each_nums1 in nums2 and each_nums1 not in intersection_list:
                        intersection_list.append(each_nums1)
            else:
                for each_nums2 in nums2:
                    if each_nums2 in nums1 and each_nums2 not in intersection_list:
                        intersection_list.append(each_nums2)
            return intersection_list
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.