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