mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2026-03-13 10:02:05 +08:00
12 KiB
12 KiB
title, type, weight
| title | type | weight |
|---|---|---|
| 2.06 Tree | docs | 6 |
Tree
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity | Favorite | Acceptance |
|---|---|---|---|---|---|---|---|
| 0094 | Binary Tree Inorder Traversal | [Go]({{< relref "/ChapterFour/0001~0099/0094.Binary-Tree-Inorder-Traversal.md" >}}) | Easy | O(n) | O(1) | 70.2% | |
| 0095 | Unique Binary Search Trees II | [Go]({{< relref "/ChapterFour/0001~0099/0095.Unique-Binary-Search-Trees-II.md" >}}) | Medium | 48.8% | |||
| 0096 | Unique Binary Search Trees | [Go]({{< relref "/ChapterFour/0001~0099/0096.Unique-Binary-Search-Trees.md" >}}) | Medium | O(n^2) | O(n) | 57.9% | |
| 0098 | Validate Binary Search Tree | [Go]({{< relref "/ChapterFour/0001~0099/0098.Validate-Binary-Search-Tree.md" >}}) | Medium | O(n) | O(1) | 30.3% | |
| 0099 | Recover Binary Search Tree | [Go]({{< relref "/ChapterFour/0001~0099/0099.Recover-Binary-Search-Tree.md" >}}) | Medium | O(n) | O(1) | 45.9% | |
| 0100 | Same Tree | [Go]({{< relref "/ChapterFour/0100~0199/0100.Same-Tree.md" >}}) | Easy | O(n) | O(1) | 55.3% | |
| 0101 | Symmetric Tree | [Go]({{< relref "/ChapterFour/0100~0199/0101.Symmetric-Tree.md" >}}) | Easy | O(n) | O(1) | 51.2% | |
| 0102 | Binary Tree Level Order Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0102.Binary-Tree-Level-Order-Traversal.md" >}}) | Medium | O(n) | O(1) | 60.4% | |
| 0103 | Binary Tree Zigzag Level Order Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0103.Binary-Tree-Zigzag-Level-Order-Traversal.md" >}}) | Medium | O(n) | O(n) | 53.1% | |
| 0104 | Maximum Depth of Binary Tree | [Go]({{< relref "/ChapterFour/0100~0199/0104.Maximum-Depth-of-Binary-Tree.md" >}}) | Easy | O(n) | O(1) | 71.4% | |
| 0105 | Construct Binary Tree from Preorder and Inorder Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal.md" >}}) | Medium | 56.9% | |||
| 0106 | Construct Binary Tree from Inorder and Postorder Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal.md" >}}) | Medium | 54.8% | |||
| 0107 | Binary Tree Level Order Traversal II | [Go]({{< relref "/ChapterFour/0100~0199/0107.Binary-Tree-Level-Order-Traversal-II.md" >}}) | Medium | O(n) | O(1) | 58.2% | |
| 0108 | Convert Sorted Array to Binary Search Tree | [Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}}) | Easy | O(n) | O(1) | 65.4% | |
| 0109 | Convert Sorted List to Binary Search Tree | [Go]({{< relref "/ChapterFour/0100~0199/0109.Convert-Sorted-List-to-Binary-Search-Tree.md" >}}) | Medium | 55.0% | |||
| 0110 | Balanced Binary Tree | [Go]({{< relref "/ChapterFour/0100~0199/0110.Balanced-Binary-Tree.md" >}}) | Easy | O(n) | O(1) | 46.4% | |
| 0111 | Minimum Depth of Binary Tree | [Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}}) | Easy | O(n) | O(1) | 42.1% | |
| 0112 | Path Sum | [Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}}) | Easy | O(n) | O(1) | 45.1% | |
| 0113 | Path Sum II | [Go]({{< relref "/ChapterFour/0100~0199/0113.Path-Sum-II.md" >}}) | Medium | O(n) | O(1) | 53.5% | |
| 0114 | Flatten Binary Tree to Linked List | [Go]({{< relref "/ChapterFour/0100~0199/0114.Flatten-Binary-Tree-to-Linked-List.md" >}}) | Medium | O(n) | O(1) | 57.1% | |
| 0116 | Populating Next Right Pointers in Each Node | [Go]({{< relref "/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md" >}}) | Medium | 56.1% | |||
| 0124 | Binary Tree Maximum Path Sum | [Go]({{< relref "/ChapterFour/0100~0199/0124.Binary-Tree-Maximum-Path-Sum.md" >}}) | Hard | O(n) | O(1) | 37.4% | |
| 0129 | Sum Root to Leaf Numbers | [Go]({{< relref "/ChapterFour/0100~0199/0129.Sum-Root-to-Leaf-Numbers.md" >}}) | Medium | O(n) | O(1) | 56.2% | |
| 0144 | Binary Tree Preorder Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0144.Binary-Tree-Preorder-Traversal.md" >}}) | Easy | O(n) | O(1) | 61.8% | |
| 0145 | Binary Tree Postorder Traversal | [Go]({{< relref "/ChapterFour/0100~0199/0145.Binary-Tree-Postorder-Traversal.md" >}}) | Easy | O(n) | O(1) | 63.2% | |
| 0173 | Binary Search Tree Iterator | [Go]({{< relref "/ChapterFour/0100~0199/0173.Binary-Search-Tree-Iterator.md" >}}) | Medium | O(n) | O(1) | 65.1% | |
| 0199 | Binary Tree Right Side View | [Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}}) | Medium | O(n) | O(1) | 59.2% | |
| 0222 | Count Complete Tree Nodes | [Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}}) | Medium | O(n) | O(1) | 54.6% | |
| 0226 | Invert Binary Tree | [Go]({{< relref "/ChapterFour/0200~0299/0226.Invert-Binary-Tree.md" >}}) | Easy | O(n) | O(1) | 71.0% | |
| 0230 | Kth Smallest Element in a BST | [Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}}) | Medium | O(n) | O(1) | 66.2% | |
| 0235 | Lowest Common Ancestor of a Binary Search Tree | [Go]({{< relref "/ChapterFour/0200~0299/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree.md" >}}) | Easy | O(n) | O(1) | 56.4% | |
| 0236 | Lowest Common Ancestor of a Binary Tree | [Go]({{< relref "/ChapterFour/0200~0299/0236.Lowest-Common-Ancestor-of-a-Binary-Tree.md" >}}) | Medium | O(n) | O(1) | 54.5% | |
| 0257 | Binary Tree Paths | [Go]({{< relref "/ChapterFour/0200~0299/0257.Binary-Tree-Paths.md" >}}) | Easy | O(n) | O(1) | 58.0% | |
| 0297 | Serialize and Deserialize Binary Tree | [Go]({{< relref "/ChapterFour/0200~0299/0297.Serialize-and-Deserialize-Binary-Tree.md" >}}) | Hard | 53.2% | |||
| 0331 | Verify Preorder Serialization of a Binary Tree | [Go]({{< relref "/ChapterFour/0300~0399/0331.Verify-Preorder-Serialization-of-a-Binary-Tree.md" >}}) | Medium | 43.6% | |||
| 0337 | House Robber III | [Go]({{< relref "/ChapterFour/0300~0399/0337.House-Robber-III.md" >}}) | Medium | 53.4% | |||
| 0341 | Flatten Nested List Iterator | [Go]({{< relref "/ChapterFour/0300~0399/0341.Flatten-Nested-List-Iterator.md" >}}) | Medium | 58.3% | |||
| 0404 | Sum of Left Leaves | [Go]({{< relref "/ChapterFour/0400~0499/0404.Sum-of-Left-Leaves.md" >}}) | Easy | O(n) | O(1) | 54.6% | |
| 0429 | N-ary Tree Level Order Traversal | [Go]({{< relref "/ChapterFour/0400~0499/0429.N-ary-Tree-Level-Order-Traversal.md" >}}) | Medium | 68.6% | |||
| 0437 | Path Sum III | [Go]({{< relref "/ChapterFour/0400~0499/0437.Path-Sum-III.md" >}}) | Medium | O(n) | O(1) | 50.1% | |
| 0508 | Most Frequent Subtree Sum | [Go]({{< relref "/ChapterFour/0500~0599/0508.Most-Frequent-Subtree-Sum.md" >}}) | Medium | 62.3% | |||
| 0513 | Find Bottom Left Tree Value | [Go]({{< relref "/ChapterFour/0500~0599/0513.Find-Bottom-Left-Tree-Value.md" >}}) | Medium | 64.9% | |||
| 0515 | Find Largest Value in Each Tree Row | [Go]({{< relref "/ChapterFour/0500~0599/0515.Find-Largest-Value-in-Each-Tree-Row.md" >}}) | Medium | O(n) | O(n) | 64.2% | |
| 0530 | Minimum Absolute Difference in BST | [Go]({{< relref "/ChapterFour/0500~0599/0530.Minimum-Absolute-Difference-in-BST.md" >}}) | Easy | 56.1% | |||
| 0538 | Convert BST to Greater Tree | [Go]({{< relref "/ChapterFour/0500~0599/0538.Convert-BST-to-Greater-Tree.md" >}}) | Medium | 62.5% | |||
| 0543 | Diameter of Binary Tree | [Go]({{< relref "/ChapterFour/0500~0599/0543.Diameter-of-Binary-Tree.md" >}}) | Easy | 53.6% | |||
| 0559 | Maximum Depth of N-ary Tree | [Go]({{< relref "/ChapterFour/0500~0599/0559.Maximum-Depth-of-N-ary-Tree.md" >}}) | Easy | 70.8% | |||
| 0563 | Binary Tree Tilt | [Go]({{< relref "/ChapterFour/0500~0599/0563.Binary-Tree-Tilt.md" >}}) | Easy | 58.2% | |||
| 0572 | Subtree of Another Tree | [Go]({{< relref "/ChapterFour/0500~0599/0572.Subtree-of-Another-Tree.md" >}}) | Easy | 45.2% | |||
| 0589 | N-ary Tree Preorder Traversal | [Go]({{< relref "/ChapterFour/0500~0599/0589.N-ary-Tree-Preorder-Traversal.md" >}}) | Easy | 75.7% | |||
| 0617 | Merge Two Binary Trees | [Go]({{< relref "/ChapterFour/0600~0699/0617.Merge-Two-Binary-Trees.md" >}}) | Easy | 77.6% | |||
| 0623 | Add One Row to Tree | [Go]({{< relref "/ChapterFour/0600~0699/0623.Add-One-Row-to-Tree.md" >}}) | Medium | 53.7% | |||
| 0637 | Average of Levels in Binary Tree | [Go]({{< relref "/ChapterFour/0600~0699/0637.Average-of-Levels-in-Binary-Tree.md" >}}) | Easy | O(n) | O(n) | 68.3% | |
| 0653 | Two Sum IV - Input is a BST | [Go]({{< relref "/ChapterFour/0600~0699/0653.Two-Sum-IV-Input-is-a-BST.md" >}}) | Easy | 58.6% | |||
| 0662 | Maximum Width of Binary Tree | [Go]({{< relref "/ChapterFour/0600~0699/0662.Maximum-Width-of-Binary-Tree.md" >}}) | Medium | 40.2% | |||
| 0669 | Trim a Binary Search Tree | [Go]({{< relref "/ChapterFour/0600~0699/0669.Trim-a-Binary-Search-Tree.md" >}}) | Medium | 64.5% | |||
| 0700 | Search in a Binary Search Tree | [Go]({{< relref "/ChapterFour/0700~0799/0700.Search-in-a-Binary-Search-Tree.md" >}}) | Easy | 75.1% | |||
| 0701 | Insert into a Binary Search Tree | [Go]({{< relref "/ChapterFour/0700~0799/0701.Insert-into-a-Binary-Search-Tree.md" >}}) | Medium | 75.0% | |||
| 0703 | Kth Largest Element in a Stream | [Go]({{< relref "/ChapterFour/0700~0799/0703.Kth-Largest-Element-in-a-Stream.md" >}}) | Easy | 52.6% | |||
| 0783 | Minimum Distance Between BST Nodes | [Go]({{< relref "/ChapterFour/0700~0799/0783.Minimum-Distance-Between-BST-Nodes.md" >}}) | Easy | 55.8% | |||
| 0834 | Sum of Distances in Tree | [Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}}) | Hard | 52.7% | |||
| 0863 | All Nodes Distance K in Binary Tree | [Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}}) | Medium | 60.7% | |||
| 0872 | Leaf-Similar Trees | [Go]({{< relref "/ChapterFour/0800~0899/0872.Leaf-Similar-Trees.md" >}}) | Easy | 64.9% | |||
| 0897 | Increasing Order Search Tree | [Go]({{< relref "/ChapterFour/0800~0899/0897.Increasing-Order-Search-Tree.md" >}}) | Easy | 76.0% | |||
| 0938 | Range Sum of BST | [Go]({{< relref "/ChapterFour/0900~0999/0938.Range-Sum-of-BST.md" >}}) | Easy | 84.9% | |||
| 0958 | Check Completeness of a Binary Tree | [Go]({{< relref "/ChapterFour/0900~0999/0958.Check-Completeness-of-a-Binary-Tree.md" >}}) | Medium | 53.5% | |||
| 0968 | Binary Tree Cameras | [Go]({{< relref "/ChapterFour/0900~0999/0968.Binary-Tree-Cameras.md" >}}) | Hard | 41.7% | |||
| 0971 | Flip Binary Tree To Match Preorder Traversal | [Go]({{< relref "/ChapterFour/0900~0999/0971.Flip-Binary-Tree-To-Match-Preorder-Traversal.md" >}}) | Medium | 49.9% | |||
| 0979 | Distribute Coins in Binary Tree | [Go]({{< relref "/ChapterFour/0900~0999/0979.Distribute-Coins-in-Binary-Tree.md" >}}) | Medium | 71.3% | |||
| 0987 | Vertical Order Traversal of a Binary Tree | [Go]({{< relref "/ChapterFour/0900~0999/0987.Vertical-Order-Traversal-of-a-Binary-Tree.md" >}}) | Hard | 41.1% | |||
| 0993 | Cousins in Binary Tree | [Go]({{< relref "/ChapterFour/0900~0999/0993.Cousins-in-Binary-Tree.md" >}}) | Easy | O(n) | O(1) | 53.7% | |
| 1026 | Maximum Difference Between Node and Ancestor | [Go]({{< relref "/ChapterFour/1000~1099/1026.Maximum-Difference-Between-Node-and-Ancestor.md" >}}) | Medium | 73.1% | |||
| 1028 | Recover a Tree From Preorder Traversal | [Go]({{< relref "/ChapterFour/1000~1099/1028.Recover-a-Tree-From-Preorder-Traversal.md" >}}) | Hard | 72.2% | |||
| 1038 | Binary Search Tree to Greater Sum Tree | [Go]({{< relref "/ChapterFour/1000~1099/1038.Binary-Search-Tree-to-Greater-Sum-Tree.md" >}}) | Medium | 84.4% | |||
| 1104 | Path In Zigzag Labelled Binary Tree | [Go]({{< relref "/ChapterFour/1100~1199/1104.Path-In-Zigzag-Labelled-Binary-Tree.md" >}}) | Medium | 74.4% | |||
| 1110 | Delete Nodes And Return Forest | [Go]({{< relref "/ChapterFour/1100~1199/1110.Delete-Nodes-And-Return-Forest.md" >}}) | Medium | 69.2% | |||
| 1123 | Lowest Common Ancestor of Deepest Leaves | [Go]({{< relref "/ChapterFour/1100~1199/1123.Lowest-Common-Ancestor-of-Deepest-Leaves.md" >}}) | Medium | 69.8% | |||
| 1145 | Binary Tree Coloring Game | [Go]({{< relref "/ChapterFour/1100~1199/1145.Binary-Tree-Coloring-Game.md" >}}) | Medium | 51.1% | |||
| 1302 | Deepest Leaves Sum | [Go]({{< relref "/ChapterFour/1300~1399/1302.Deepest-Leaves-Sum.md" >}}) | Medium | 85.7% | |||
| 1305 | All Elements in Two Binary Search Trees | [Go]({{< relref "/ChapterFour/1300~1399/1305.All-Elements-in-Two-Binary-Search-Trees.md" >}}) | Medium | 79.6% | |||
| 1600 | Throne Inheritance | [Go]({{< relref "/ChapterFour/1600~1699/1600.Throne-Inheritance.md" >}}) | Medium | 62.9% | |||
| 1609 | Even Odd Tree | [Go]({{< relref "/ChapterFour/1600~1699/1609.Even-Odd-Tree.md" >}}) | Medium | 52.9% | |||
| ------------ | ------------------------------------------------------- | ------- | ---------------- | --------------- | ------------- | ------------- | ------------- |