Skip to content

Commit af49301

Browse files
committed
feat: 0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal
1 parent 36d71fd commit af49301

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Leetcode/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: "0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal"
1010
license: ""
1111
images: []
1212

13-
tags: [LeetCode, Go, Medium, Construct Binary Tree from Preorder and Inorder Traversal]
13+
tags: [LeetCode, Go, Medium, Construct Binary Tree from Preorder and Inorder Traversal, Array,Hash Table,Divide and Conquer,Tree, Binary Tree]
1414
categories: [LeetCode]
1515

1616
featuredImage: ""
@@ -68,8 +68,13 @@ seo:
6868
## 解題思路
6969

7070
## Big O
71-
時間複雜 : ``
72-
空間複雜 : ``
71+
* 時間複雜 : `O(n)`
72+
n個樹節點
73+
74+
* 空間複雜 : `O(n)`
75+
遞迴調用的Stack空間是 O(h),其中 h 是樹的高度。
76+
在每個遞迴層級中,都創建了一個 TreeNode 對象,因此空間複雜度也是 O(n),其中 n 是節點的數量。
77+
h< n所以空間複雜為 O(n)
7378

7479
## 來源
7580
* https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/description/

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,14 @@ int binarySearch(int[] nums, int target){
408408
---
409409

410410
#### Tree
411-
| No. | Title | Solution | Difficulty | Time | Space | Topic |
412-
|-----------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------:|------------|------|-----------------|-----------|
413-
| [0226](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0226.Invert-Binary-Tree) | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0226.Invert-Binary-Tree) | Easy | O(n) | O(1) | Tree |
414-
| [0104](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0104.Maximum-Depth-of-Binary-Tree/) | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree//description/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0104.Maximum-Depth-of-Binary-Tree) | Easy | O(n) | O(1) | Tree |
415-
| [0543](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0543.Diameter-of-Binary-Tree) | [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0543.Diameter-of-Binary-Tree) | Easy | O(n) | O(n), O(log(n)) | Tree, DFS |
416-
| [0110](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0110.Balanced-Binary-Tree) | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0110.Balanced-Binary-Tree) | Easy | O(n) | O(1) | Tree, DFS |
417-
| [0100](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0100.Same-Tree) | [Same Tree](https://leetcode.com/problems/same-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0100.Same-Tree) | Easy | O(n) | O(1) | Tree |
411+
| No. | Title | Solution | Difficulty | Time | Space | Topic |
412+
|---------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------:|------------|------|-----------------|-----------|
413+
| [0226](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0226.Invert-Binary-Tree) | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0226.Invert-Binary-Tree) | Easy | O(n) | O(1) | Tree |
414+
| [0104](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0104.Maximum-Depth-of-Binary-Tree/) | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree//description/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0104.Maximum-Depth-of-Binary-Tree) | Easy | O(n) | O(1) | Tree |
415+
| [0543](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0543.Diameter-of-Binary-Tree) | [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0543.Diameter-of-Binary-Tree) | Easy | O(n) | O(n), O(log(n)) | Tree, DFS |
416+
| [0110](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0110.Balanced-Binary-Tree) | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0110.Balanced-Binary-Tree) | Easy | O(n) | O(1) | Tree, DFS |
417+
| [0100](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0100.Same-Tree) | [Same Tree](https://leetcode.com/problems/same-tree/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0100.Same-Tree) | Easy | O(n) | O(1) | Tree |
418+
| [0105](https://kimi0230.github.io/LeetcodeGolang/Leetcode/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal) | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/description/) | [Go](https://github.com/kimi0230/LeetcodeGolang/tree/master/Leetcode/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal) | Medium | O(n) | O(n) | Array |
418419

419420
---
420421

0 commit comments

Comments
 (0)