일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- kaggle
- Class
- 715. Range Module
- Protocol
- Generator
- Python Code
- 파이썬
- data science
- concurrency
- Regular Expression
- iterator
- 43. Multiply Strings
- t1
- 프로그래머스
- 밴픽
- LeetCode
- 운영체제
- 시바견
- Substring with Concatenation of All Words
- Python
- shiba
- attribute
- Decorator
- Python Implementation
- DWG
- 컴퓨터의 구조
- 315. Count of Smaller Numbers After Self
- 109. Convert Sorted List to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
Archives
- Today
- Total
목록102. Binary Tree Level Order Traversal (1)
Scribbling
LeetCode: 102. Binary Tree Level Order Traversal
BFS하면서 기록해준다. from collections import deque # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def levelOrder(self, root: Optional[TreeNode]) -> List[List[int]]: if not root: return [] ret = [] q = deque() q.append((root, 0)) while q: cur_node, cur_level = q.popleft() ..
Computer Science/Coding Test
2021. 10. 20. 16:15