일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 컴퓨터의 구조
- LeetCode
- Class
- Protocol
- Regular Expression
- Python Implementation
- 315. Count of Smaller Numbers After Self
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- attribute
- 운영체제
- Decorator
- 파이썬
- 30. Substring with Concatenation of All Words
- shiba
- DWG
- 715. Range Module
- t1
- kaggle
- Python
- Substring with Concatenation of All Words
- iterator
- Generator
- 프로그래머스
- Python Code
- 밴픽
- 43. Multiply Strings
- 시바견
- concurrency
- data science
Archives
- Today
- Total
Scribbling
LeetCode: 350. Intersection of Two Arrays II 본문
Computer Science/Coding Test
LeetCode: 350. Intersection of Two Arrays II
focalpoint 2022. 1. 10. 22:04Using double counters.
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
from collections import Counter
c1 = Counter(nums1)
c2 = Counter(nums2)
ret = []
for k in c2.keys():
ret.extend([k] * min(c1[k], c2[k]))
return ret
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 334. Increasing Triplet Subsequence (0) | 2022.01.11 |
---|---|
LeetCode: 329. Longest Increasing Path in a Matrix (0) | 2022.01.11 |
LeetCode: 322. Coin Change (0) | 2022.01.07 |
LeetCode: 21. Merge Two Sorted Lists (0) | 2022.01.05 |
LeetCode: 442. Find All Duplicates in an Array (0) | 2022.01.05 |