일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 715. Range Module
- attribute
- Protocol
- 프로그래머스
- Decorator
- Python
- shiba
- Class
- Python Implementation
- Python Code
- Convert Sorted List to Binary Search Tree
- 시바견
- 밴픽
- 파이썬
- data science
- 컴퓨터의 구조
- 315. Count of Smaller Numbers After Self
- Regular Expression
- concurrency
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- 운영체제
- iterator
- t1
- 43. Multiply Strings
- kaggle
- Generator
- DWG
- LeetCode
Archives
- Today
- Total
목록Populating Next Right Pointers in Each Node (1)
Scribbling
LeetCode: 116. Populating Next Right Pointers in Each Node
O(N) 메모리를 사용한다면 매우 쉬운 문제이지만, 아래 Follow-up을 반영하여 O(1) 메모리를 사용하여 푸는 것은 조금 생각이 필요하다. Constant Memory로 어찌 풀지 생각하다가 아래 조건에서 힌트를 얻었다. Node의 개수에 제한이 있다는 것. Perfect Binary Tree에서 이와 같은 조건은 곧 최대 높이로 직결된다. 이를 활용하면, 트리의 층마다 last node 주소를 저장해놓고 갱신하는 방식으로 풀 수 있다. """ # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val..
Computer Science/Coding Test
2021. 11. 2. 14:42