We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ec197d commit 84326d9Copy full SHA for 84326d9
problems/0349.两个数组的交集.md
@@ -169,6 +169,21 @@ class Solution:
169
val_dict[num] = 0
170
171
return ans
172
+
173
+class Solution: # 使用数组方法
174
+ def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
175
+ count1 = [0]*1001
176
+ count2 = [0]*1001
177
+ result = []
178
+ for i in range(len(nums1)):
179
+ count1[nums1[i]]+=1
180
+ for j in range(len(nums2)):
181
+ count2[nums2[j]]+=1
182
+ for k in range(1001):
183
+ if count1[k]*count2[k]>0:
184
+ result.append(k)
185
+ return result
186
187
```
188
189
0 commit comments