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