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