Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- sort
- LeetCode
- 컴퓨터공학
- Data_Structure
- CNN
- SQL
- GNN
- 데베
- code
- Leet Code
- meshgraphnet
- 코딩테스트
- mysql
- db
- DS
- Python
- 데이터
- 코테
- 데이터베이스
- 티스토리챌린지
- coding
- adaptive remeshing
- 컴퓨터사이언스
- 오블완
- CS
- 자료구조
- 대학생
- Database
- 개발자
- Mesh
Archives
- Today
- Total
sy1214ei 님의 블로그
[Leet Code] 349. Intersection of Two Arrays - Python 본문
https://leetcode.com/problems/intersection-of-two-arrays/description/
level : Easy
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
"""
1. nums1에 있는 값은 모두 True
2. nums2에 nums1에 있는 값이 있다면 res.add
3. return list(res) : res에는 num1, num2의 겹치는 값들 다 들어감
"""
hash_table = {}
for num in nums1:
hash_table[num] = True
result = set()
for num in nums2:
if num in hash_table:
result.add(num)
return list(result)
# Time Complexity : O(n)
# Space Complexity : O(n)

'[Coding]' 카테고리의 다른 글
| [Leet Code] 500. Keyboard Row - Python (0) | 2024.12.23 |
|---|---|
| [Leet Code] 3. Longest Substring Without Repeating Characters (0) | 2024.12.16 |
| [Leet Code] 41. First Missing Positive - Python (1) | 2024.12.16 |
| [Leet Code] 409. Longest Palindrome - Python (2) | 2024.12.04 |
| [Leet Code] 1. Two Sum - Python (0) | 2024.12.03 |