일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Protocol
- 109. Convert Sorted List to Binary Search Tree
- Class
- kaggle
- 밴픽
- attribute
- LeetCode
- 43. Multiply Strings
- 30. Substring with Concatenation of All Words
- data science
- iterator
- Generator
- 운영체제
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- 시바견
- DWG
- Decorator
- t1
- Python
- 파이썬
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- Python Code
- Python Implementation
- shiba
- Regular Expression
- 프로그래머스
- concurrency
- 715. Range Module
Archives
- Today
- Total
목록Serialize and Deserialize Binary Tree (1)
Scribbling
LeetCode: 297. Serialize and Deserialize Binary Tree
My somewhat complicated code using queue. Both time and memory complexities are O(N). # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: TreeNode :rtype: str """ if not root: return '' ret = str(root.val) + ' ' q = [r..
Computer Science/Coding Test
2022. 1. 2. 19:08