| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 43. Multiply Strings
- data science
- 시바견
- DWG
- 30. Substring with Concatenation of All Words
- 컴퓨터의 구조
- iterator
- Python
- 운영체제
- 315. Count of Smaller Numbers After Self
- Decorator
- Generator
- Protocol
- attribute
- LeetCode
- 파이썬
- shiba
- concurrency
- Python Implementation
- 109. Convert Sorted List to Binary Search Tree
- Regular Expression
- Python Code
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 프로그래머스
- Class
- 밴픽
- kaggle
- t1
- 715. Range Module
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 |