File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ # [ Problem 350: Intersection of Two Arrays II] ( https://leetcode.com/problems/intersection-of-two-arrays-ii/description/ )
2+
3+ ## Initial thoughts (stream-of-consciousness)
4+ first order of business is figuring out which elements are present in both; second is getting the number of times
5+
6+ ## Refining the problem
7+
8+ ## Attempted solution(s)
9+ ```
10+ class Solution(object):
11+ def intersect(self, nums1, nums2):
12+ """
13+ :type nums1: List[int]
14+ :type nums2: List[int]
15+ :rtype: List[int]
16+ """
17+ intersection = []
18+ for x in set(nums1).intersection(set(nums2)):
19+ intersection.extend([x]*min(nums1.count(x), nums2.count(x)))
20+ return intersection
21+ ```
22+ <img width =" 611 " alt =" Screen Shot 2024-07-04 at 4 27 44 PM " src =" https://github.com/KatieONell/leetcode-solutions/assets/12962290/eda945af-174a-4b98-b6b2-0332b9db4fd6 " >
You can’t perform that action at this time.
0 commit comments