SImple Python solution


  • 2
    B
    class Solution(object):
    def intersect(self, nums1, nums2):
        result = []
        for i in range(len(nums1)):
            if nums1[i] in nums2:
                nums2.remove(nums1[i])
                result.append(nums1[i])
        return result

  • 0
    J

    Good solution: alter the data as you comb through it so as to track progress. Wish I'd thought of it.


Log in to reply
 

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