标签:
一、前言
做了两题才慢慢摸清了leetcode的操作。
二、题349 Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.
class Solution(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ nums3=[] nums4=[] i=0 j=0 for i in range(0, len(nums1)): if nums1[i] not in nums3: nums3.append(nums1[i]) for j in range(0,len(nums2)): if nums2[j] in nums3 and nums2[j] not in nums4: nums4.append(nums2[j]) return nums4
其实前两题不难,思路也还比较清晰。
Leetcode刷题记录[python]——349 Intersection of Two Arrays
标签:
原文地址:http://www.cnblogs.com/Myoungs/p/5509635.html