Skip to content

Commit 29e3a99

Browse files
authored
Merge pull request #27 from programmingbookclub/35-2021-12-14-Binary-tree.md
Create 35 2021-12-14 Binary tree.md
2 parents 5e2fb12 + 46cca38 commit 29e3a99

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

紀錄/35 2021-12-14 Binary tree.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# LeetCode 讀書會第 35 次聚會 2021/12/14
2+
3+
## leetcode 讀書會通知
4+
5+
1. 項目: 第 35 次聚會
6+
2. 目的: 線上一起寫題目, 由有想法的人帶領, 先解題, 再看該題有趣的解法
7+
3. 時間: 12/14 (二) 20:00 ~ 21:00
8+
4. 地點: google meet 線上 (前 10 分鐘預備鏈接)
9+
5. 解題項目: [Binary Tree](https://leetcode.com/explore/learn/card/data-structure-tree/)
10+
6. 共筆: GitHub https://github.com/programmingbookclub/Leetcode-club
11+
7. 備註:
12+
13+
當然這次要說到 3 題 MEDIUM!(立 Flag!) 116、117、236
14+
15+
16+
* MEDIUM 116 Populating Next Right Pointers in Each Node https://leetcode.com/problems/populating-next-right-pointers-in-each-node
17+
* MEDIUM 117 Populating Next Right Pointers in Each Node II https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii
18+
* MEDIUM 236 Lowest Common Ancestor of a Binary Tree https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
19+
* HARD 297 Serialize and Deserialize Binary Tree https://leetcode.com/problems/serialize-and-deserialize-binary-tree
20+
21+
---
22+
Notes:
23+
24+
116: perfect binary tree
25+
1. using queue(level order) to travsal
26+
2. using
27+
28+
```swift=
29+
func connect(_ root: Node?,_ next: Node? = nil) -> Node? {
30+
guard let root = root else {return nil}
31+
root.next = next
32+
connect(root.left, root.right)
33+
connect(root.right, root.next?.left)
34+
return root
35+
}
36+
```
37+
38+
117:
39+
Discussion 的第一個,看起來跟 Solution 的這個解法相同
40+
https://leetcode.com/explore/learn/card/data-structure-tree/133/conclusion/1016/discuss/37828/O(1)-space-O(n)-complexity-Iterative-Solution
41+
42+
43+
236 swift with switch https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/discuss/1626458/Swift-with-switch

0 commit comments

Comments
 (0)