Back to Leetcode Go

2.06 Tree

website/content/ChapterTwo/Tree.md

1.7.112.2 KB
Original Source

Tree

No.TitleSolutionDifficultyTimeComplexitySpaceComplexityFavoriteAcceptance
0094Binary Tree Inorder Traversal[Go]({{< relref "/ChapterFour/0001~0099/0094.Binary-Tree-Inorder-Traversal.md" >}})EasyO(n)O(1)73.8%
0095Unique Binary Search Trees II[Go]({{< relref "/ChapterFour/0001~0099/0095.Unique-Binary-Search-Trees-II.md" >}})Medium52.3%
0096Unique Binary Search Trees[Go]({{< relref "/ChapterFour/0001~0099/0096.Unique-Binary-Search-Trees.md" >}})MediumO(n^2)O(n)59.6%
0098Validate Binary Search Tree[Go]({{< relref "/ChapterFour/0001~0099/0098.Validate-Binary-Search-Tree.md" >}})MediumO(n)O(1)32.0%
0099Recover Binary Search Tree[Go]({{< relref "/ChapterFour/0001~0099/0099.Recover-Binary-Search-Tree.md" >}})MediumO(n)O(1)51.0%
0100Same Tree[Go]({{< relref "/ChapterFour/0100~0199/0100.Same-Tree.md" >}})EasyO(n)O(1)58.1%
0101Symmetric Tree[Go]({{< relref "/ChapterFour/0100~0199/0101.Symmetric-Tree.md" >}})EasyO(n)O(1)54.3%
0102Binary Tree Level Order Traversal[Go]({{< relref "/ChapterFour/0100~0199/0102.Binary-Tree-Level-Order-Traversal.md" >}})MediumO(n)O(1)64.3%
0103Binary Tree Zigzag Level Order Traversal[Go]({{< relref "/ChapterFour/0100~0199/0103.Binary-Tree-Zigzag-Level-Order-Traversal.md" >}})MediumO(n)O(n)56.9%
0104Maximum Depth of Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0104.Maximum-Depth-of-Binary-Tree.md" >}})EasyO(n)O(1)73.9%
0105Construct Binary Tree from Preorder and Inorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal.md" >}})Medium61.5%
0106Construct Binary Tree from Inorder and Postorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal.md" >}})Medium60.0%
0107Binary Tree Level Order Traversal II[Go]({{< relref "/ChapterFour/0100~0199/0107.Binary-Tree-Level-Order-Traversal-II.md" >}})MediumO(n)O(1)61.1%
0108Convert Sorted Array to Binary Search Tree[Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}})EasyO(n)O(1)69.8%
0109Convert Sorted List to Binary Search Tree[Go]({{< relref "/ChapterFour/0100~0199/0109.Convert-Sorted-List-to-Binary-Search-Tree.md" >}})Medium60.2%
0110Balanced Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0110.Balanced-Binary-Tree.md" >}})EasyO(n)O(1)49.0%
0111Minimum Depth of Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}})EasyO(n)O(1)44.4%
0112Path Sum[Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}})EasyO(n)O(1)48.2%
0113Path Sum II[Go]({{< relref "/ChapterFour/0100~0199/0113.Path-Sum-II.md" >}})MediumO(n)O(1)57.1%
0114Flatten Binary Tree to Linked List[Go]({{< relref "/ChapterFour/0100~0199/0114.Flatten-Binary-Tree-to-Linked-List.md" >}})MediumO(n)O(1)61.8%
0116Populating Next Right Pointers in Each Node[Go]({{< relref "/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md" >}})Medium60.4%
0124Binary Tree Maximum Path Sum[Go]({{< relref "/ChapterFour/0100~0199/0124.Binary-Tree-Maximum-Path-Sum.md" >}})HardO(n)O(1)39.2%
0129Sum Root to Leaf Numbers[Go]({{< relref "/ChapterFour/0100~0199/0129.Sum-Root-to-Leaf-Numbers.md" >}})MediumO(n)O(1)61.0%
0144Binary Tree Preorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0144.Binary-Tree-Preorder-Traversal.md" >}})EasyO(n)O(1)66.8%
0145Binary Tree Postorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0145.Binary-Tree-Postorder-Traversal.md" >}})EasyO(n)O(1)67.9%
0173Binary Search Tree Iterator[Go]({{< relref "/ChapterFour/0100~0199/0173.Binary-Search-Tree-Iterator.md" >}})MediumO(n)O(1)69.7%
0199Binary Tree Right Side View[Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}})MediumO(n)O(1)61.6%
0222Count Complete Tree Nodes[Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}})MediumO(n)O(1)60.5%
0226Invert Binary Tree[Go]({{< relref "/ChapterFour/0200~0299/0226.Invert-Binary-Tree.md" >}})EasyO(n)O(1)74.7%
0230Kth Smallest Element in a BST[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})MediumO(n)O(1)70.1%
0235Lowest Common Ancestor of a Binary Search Tree[Go]({{< relref "/ChapterFour/0200~0299/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree.md" >}})MediumO(n)O(1)61.5%
0236Lowest Common Ancestor of a Binary Tree[Go]({{< relref "/ChapterFour/0200~0299/0236.Lowest-Common-Ancestor-of-a-Binary-Tree.md" >}})MediumO(n)O(1)58.8%
0257Binary Tree Paths[Go]({{< relref "/ChapterFour/0200~0299/0257.Binary-Tree-Paths.md" >}})EasyO(n)O(1)61.4%
0297Serialize and Deserialize Binary Tree[Go]({{< relref "/ChapterFour/0200~0299/0297.Serialize-and-Deserialize-Binary-Tree.md" >}})Hard55.4%
0331Verify Preorder Serialization of a Binary Tree[Go]({{< relref "/ChapterFour/0300~0399/0331.Verify-Preorder-Serialization-of-a-Binary-Tree.md" >}})Medium44.6%
0337House Robber III[Go]({{< relref "/ChapterFour/0300~0399/0337.House-Robber-III.md" >}})Medium53.9%
0341Flatten Nested List Iterator[Go]({{< relref "/ChapterFour/0300~0399/0341.Flatten-Nested-List-Iterator.md" >}})Medium61.8%
0404Sum of Left Leaves[Go]({{< relref "/ChapterFour/0400~0499/0404.Sum-of-Left-Leaves.md" >}})EasyO(n)O(1)56.7%
0429N-ary Tree Level Order Traversal[Go]({{< relref "/ChapterFour/0400~0499/0429.N-ary-Tree-Level-Order-Traversal.md" >}})Medium70.7%
0437Path Sum III[Go]({{< relref "/ChapterFour/0400~0499/0437.Path-Sum-III.md" >}})MediumO(n)O(1)48.0%
0508Most Frequent Subtree Sum[Go]({{< relref "/ChapterFour/0500~0599/0508.Most-Frequent-Subtree-Sum.md" >}})Medium64.9%
0513Find Bottom Left Tree Value[Go]({{< relref "/ChapterFour/0500~0599/0513.Find-Bottom-Left-Tree-Value.md" >}})Medium66.9%
0515Find Largest Value in Each Tree Row[Go]({{< relref "/ChapterFour/0500~0599/0515.Find-Largest-Value-in-Each-Tree-Row.md" >}})MediumO(n)O(n)64.6%
0530Minimum Absolute Difference in BST[Go]({{< relref "/ChapterFour/0500~0599/0530.Minimum-Absolute-Difference-in-BST.md" >}})Easy57.3%
0538Convert BST to Greater Tree[Go]({{< relref "/ChapterFour/0500~0599/0538.Convert-BST-to-Greater-Tree.md" >}})Medium67.8%
0543Diameter of Binary Tree[Go]({{< relref "/ChapterFour/0500~0599/0543.Diameter-of-Binary-Tree.md" >}})Easy56.8%
0559Maximum Depth of N-ary Tree[Go]({{< relref "/ChapterFour/0500~0599/0559.Maximum-Depth-of-N-ary-Tree.md" >}})Easy71.7%
0563Binary Tree Tilt[Go]({{< relref "/ChapterFour/0500~0599/0563.Binary-Tree-Tilt.md" >}})Easy60.0%
0572Subtree of Another Tree[Go]({{< relref "/ChapterFour/0500~0599/0572.Subtree-of-Another-Tree.md" >}})Easy46.4%
0589N-ary Tree Preorder Traversal[Go]({{< relref "/ChapterFour/0500~0599/0589.N-ary-Tree-Preorder-Traversal.md" >}})Easy75.9%
0617Merge Two Binary Trees[Go]({{< relref "/ChapterFour/0600~0699/0617.Merge-Two-Binary-Trees.md" >}})Easy78.6%
0623Add One Row to Tree[Go]({{< relref "/ChapterFour/0600~0699/0623.Add-One-Row-to-Tree.md" >}})Medium59.5%
0637Average of Levels in Binary Tree[Go]({{< relref "/ChapterFour/0600~0699/0637.Average-of-Levels-in-Binary-Tree.md" >}})EasyO(n)O(n)71.8%
0653Two Sum IV - Input is a BST[Go]({{< relref "/ChapterFour/0600~0699/0653.Two-Sum-IV-Input-is-a-BST.md" >}})Easy61.0%
0662Maximum Width of Binary Tree[Go]({{< relref "/ChapterFour/0600~0699/0662.Maximum-Width-of-Binary-Tree.md" >}})Medium40.7%
0669Trim a Binary Search Tree[Go]({{< relref "/ChapterFour/0600~0699/0669.Trim-a-Binary-Search-Tree.md" >}})Medium66.4%
0700Search in a Binary Search Tree[Go]({{< relref "/ChapterFour/0700~0799/0700.Search-in-a-Binary-Search-Tree.md" >}})Easy77.7%
0701Insert into a Binary Search Tree[Go]({{< relref "/ChapterFour/0700~0799/0701.Insert-into-a-Binary-Search-Tree.md" >}})Medium74.3%
0703Kth Largest Element in a Stream[Go]({{< relref "/ChapterFour/0700~0799/0703.Kth-Largest-Element-in-a-Stream.md" >}})Easy55.5%
0783Minimum Distance Between BST Nodes[Go]({{< relref "/ChapterFour/0700~0799/0783.Minimum-Distance-Between-BST-Nodes.md" >}})Easy59.3%
0834Sum of Distances in Tree[Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}})Hard59.1%
0863All Nodes Distance K in Binary Tree[Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}})Medium62.2%
0872Leaf-Similar Trees[Go]({{< relref "/ChapterFour/0800~0899/0872.Leaf-Similar-Trees.md" >}})Easy67.6%
0897Increasing Order Search Tree[Go]({{< relref "/ChapterFour/0800~0899/0897.Increasing-Order-Search-Tree.md" >}})Easy78.4%
0938Range Sum of BST[Go]({{< relref "/ChapterFour/0900~0999/0938.Range-Sum-of-BST.md" >}})Easy85.9%
0958Check Completeness of a Binary Tree[Go]({{< relref "/ChapterFour/0900~0999/0958.Check-Completeness-of-a-Binary-Tree.md" >}})Medium56.2%
0968Binary Tree Cameras[Go]({{< relref "/ChapterFour/0900~0999/0968.Binary-Tree-Cameras.md" >}})Hard46.6%
0971Flip Binary Tree To Match Preorder Traversal[Go]({{< relref "/ChapterFour/0900~0999/0971.Flip-Binary-Tree-To-Match-Preorder-Traversal.md" >}})Medium50.0%
0979Distribute Coins in Binary Tree[Go]({{< relref "/ChapterFour/0900~0999/0979.Distribute-Coins-in-Binary-Tree.md" >}})Medium72.2%
0987Vertical Order Traversal of a Binary Tree[Go]({{< relref "/ChapterFour/0900~0999/0987.Vertical-Order-Traversal-of-a-Binary-Tree.md" >}})Hard45.1%
0993Cousins in Binary Tree[Go]({{< relref "/ChapterFour/0900~0999/0993.Cousins-in-Binary-Tree.md" >}})EasyO(n)O(1)54.6%
1022Sum of Root To Leaf Binary Numbers[Go]({{< relref "/ChapterFour/1000~1099/1022.Sum-of-Root-To-Leaf-Binary-Numbers.md" >}})Easy73.6%
1026Maximum Difference Between Node and Ancestor[Go]({{< relref "/ChapterFour/1000~1099/1026.Maximum-Difference-Between-Node-and-Ancestor.md" >}})Medium75.8%
1028Recover a Tree From Preorder Traversal[Go]({{< relref "/ChapterFour/1000~1099/1028.Recover-a-Tree-From-Preorder-Traversal.md" >}})Hard73.3%
1038Binary Search Tree to Greater Sum Tree[Go]({{< relref "/ChapterFour/1000~1099/1038.Binary-Search-Tree-to-Greater-Sum-Tree.md" >}})Medium85.5%
1104Path In Zigzag Labelled Binary Tree[Go]({{< relref "/ChapterFour/1100~1199/1104.Path-In-Zigzag-Labelled-Binary-Tree.md" >}})Medium75.1%
1110Delete Nodes And Return Forest[Go]({{< relref "/ChapterFour/1100~1199/1110.Delete-Nodes-And-Return-Forest.md" >}})Medium69.3%
1123Lowest Common Ancestor of Deepest Leaves[Go]({{< relref "/ChapterFour/1100~1199/1123.Lowest-Common-Ancestor-of-Deepest-Leaves.md" >}})Medium70.9%
1145Binary Tree Coloring Game[Go]({{< relref "/ChapterFour/1100~1199/1145.Binary-Tree-Coloring-Game.md" >}})Medium51.7%
1302Deepest Leaves Sum[Go]({{< relref "/ChapterFour/1300~1399/1302.Deepest-Leaves-Sum.md" >}})Medium86.7%
1305All Elements in Two Binary Search Trees[Go]({{< relref "/ChapterFour/1300~1399/1305.All-Elements-in-Two-Binary-Search-Trees.md" >}})Medium79.8%
1600Throne Inheritance[Go]({{< relref "/ChapterFour/1600~1699/1600.Throne-Inheritance.md" >}})Medium63.6%
1609Even Odd Tree[Go]({{< relref "/ChapterFour/1600~1699/1609.Even-Odd-Tree.md" >}})Medium54.3%
2096Step-By-Step Directions From a Binary Tree Node to Another[Go]({{< relref "/ChapterFour/2000~2099/2096.Step-By-Step-Directions-From-a-Binary-Tree-Node-to-Another.md" >}})Medium48.4%
------------------------------------------------------------------------------------------------------------------------------------------------

<div style="display: flex;justify-content: space-between;align-items: center;"> <p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Stack/">⬅️上一页</a></p> <p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Dynamic_Programming/">下一页➡️</a></p> </div>