Python Solution-sharing


  • 0
    C
    class Solution(object):
        def intersection(self, nums1, nums2):
            """
            :type nums1: List[int]
            :type nums2: List[int]
            :rtype: List[int]
            """
            dic = {}
            result = []
            for index1, item1 in enumerate(nums1):
                if dic.has_key(item1):
                    continue
                else:
                    dic[item1]=index1
            for index2, item2 in enumerate(nums2):
                if dic.has_key(item2):
                    if item2 in result:
                        continue
                    else:
                        result.append(item2)
                else:
                    continue
            return result

  • 0
    F
    This post is deleted!

Log in to reply
 

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