Back to Leetcode Go

2.09 Depth First Search

website/content/ChapterTwo/Depth_First_Search.md

1.7.114.3 KB
Original Source

Depth First Search

No.TitleSolutionDifficultyTimeComplexitySpaceComplexityFavoriteAcceptance
0094Binary Tree Inorder Traversal[Go]({{< relref "/ChapterFour/0001~0099/0094.Binary-Tree-Inorder-Traversal.md" >}})Easy73.8%
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.2%
0101Symmetric Tree[Go]({{< relref "/ChapterFour/0100~0199/0101.Symmetric-Tree.md" >}})EasyO(n)O(1)54.3%
0104Maximum Depth of Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0104.Maximum-Depth-of-Binary-Tree.md" >}})EasyO(n)O(1)73.9%
0110Balanced Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0110.Balanced-Binary-Tree.md" >}})EasyO(n)O(1)49.1%
0111Minimum Depth of Binary Tree[Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}})EasyO(n)O(1)44.5%
0112Path Sum[Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}})EasyO(n)O(1)48.3%
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%
0130Surrounded Regions[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})Medium36.8%
0144Binary Tree Preorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0144.Binary-Tree-Preorder-Traversal.md" >}})Easy66.9%
0145Binary Tree Postorder Traversal[Go]({{< relref "/ChapterFour/0100~0199/0145.Binary-Tree-Postorder-Traversal.md" >}})Easy68.0%
0199Binary Tree Right Side View[Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}})MediumO(n)O(1)61.6%
0200Number of Islands[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})MediumO(n^2)O(n^2)57.0%
0207Course Schedule[Go]({{< relref "/ChapterFour/0200~0299/0207.Course-Schedule.md" >}})MediumO(n^2)O(n^2)45.4%
0210Course Schedule II[Go]({{< relref "/ChapterFour/0200~0299/0210.Course-Schedule-II.md" >}})MediumO(n^2)O(n^2)48.5%
0211Design Add and Search Words Data Structure[Go]({{< relref "/ChapterFour/0200~0299/0211.Design-Add-and-Search-Words-Data-Structure.md" >}})Medium44.0%
0222Count Complete Tree Nodes[Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}})Medium60.6%
0226Invert Binary Tree[Go]({{< relref "/ChapterFour/0200~0299/0226.Invert-Binary-Tree.md" >}})Easy74.7%
0230Kth Smallest Element in a BST[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})Medium70.2%
0235Lowest Common Ancestor of a Binary Search Tree[Go]({{< relref "/ChapterFour/0200~0299/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree.md" >}})Medium61.6%
0236Lowest Common Ancestor of a Binary Tree[Go]({{< relref "/ChapterFour/0200~0299/0236.Lowest-Common-Ancestor-of-a-Binary-Tree.md" >}})Medium58.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%
0329Longest Increasing Path in a Matrix[Go]({{< relref "/ChapterFour/0300~0399/0329.Longest-Increasing-Path-in-a-Matrix.md" >}})Hard52.4%
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%
0385Mini Parser[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})Medium36.9%
0386Lexicographical Numbers[Go]({{< relref "/ChapterFour/0300~0399/0386.Lexicographical-Numbers.md" >}})Medium61.6%
0399Evaluate Division[Go]({{< relref "/ChapterFour/0300~0399/0399.Evaluate-Division.md" >}})Medium59.7%
0404Sum of Left Leaves[Go]({{< relref "/ChapterFour/0400~0499/0404.Sum-of-Left-Leaves.md" >}})Easy56.7%
0417Pacific Atlantic Water Flow[Go]({{< relref "/ChapterFour/0400~0499/0417.Pacific-Atlantic-Water-Flow.md" >}})Medium54.4%
0419Battleships in a Board[Go]({{< relref "/ChapterFour/0400~0499/0419.Battleships-in-a-Board.md" >}})Medium74.8%
0437Path Sum III[Go]({{< relref "/ChapterFour/0400~0499/0437.Path-Sum-III.md" >}})Medium48.0%
0463Island Perimeter[Go]({{< relref "/ChapterFour/0400~0499/0463.Island-Perimeter.md" >}})Easy69.7%
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%
0529Minesweeper[Go]({{< relref "/ChapterFour/0500~0599/0529.Minesweeper.md" >}})Medium65.7%
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%
0547Number of Provinces[Go]({{< relref "/ChapterFour/0500~0599/0547.Number-of-Provinces.md" >}})Medium63.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.1%
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.8%
0617Merge Two Binary Trees[Go]({{< relref "/ChapterFour/0600~0699/0617.Merge-Two-Binary-Trees.md" >}})Easy78.7%
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" >}})Easy71.7%
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%
0684Redundant Connection[Go]({{< relref "/ChapterFour/0600~0699/0684.Redundant-Connection.md" >}})Medium62.2%
0685Redundant Connection II[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})Hard34.1%
0690Employee Importance[Go]({{< relref "/ChapterFour/0600~0699/0690.Employee-Importance.md" >}})Medium65.6%
0695Max Area of Island[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})Medium71.8%
0721Accounts Merge[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})Medium56.3%
0733Flood Fill[Go]({{< relref "/ChapterFour/0700~0799/0733.Flood-Fill.md" >}})Easy62.0%
0753Cracking the Safe[Go]({{< relref "/ChapterFour/0700~0799/0753.Cracking-the-Safe.md" >}})Hard55.8%
0756Pyramid Transition Matrix[Go]({{< relref "/ChapterFour/0700~0799/0756.Pyramid-Transition-Matrix.md" >}})Medium52.7%
0765Couples Holding Hands[Go]({{< relref "/ChapterFour/0700~0799/0765.Couples-Holding-Hands.md" >}})Hard56.6%
0778Swim in Rising Water[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})Hard59.8%
0783Minimum Distance Between BST Nodes[Go]({{< relref "/ChapterFour/0700~0799/0783.Minimum-Distance-Between-BST-Nodes.md" >}})Easy59.3%
0785Is Graph Bipartite?[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})Medium53.1%
0802Find Eventual Safe States[Go]({{< relref "/ChapterFour/0800~0899/0802.Find-Eventual-Safe-States.md" >}})Medium56.6%
0834Sum of Distances in Tree[Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}})Hard59.1%
0839Similar String Groups[Go]({{< relref "/ChapterFour/0800~0899/0839.Similar-String-Groups.md" >}})Hard48.0%
0841Keys and Rooms[Go]({{< relref "/ChapterFour/0800~0899/0841.Keys-and-Rooms.md" >}})Medium71.5%
0851Loud and Rich[Go]({{< relref "/ChapterFour/0800~0899/0851.Loud-and-Rich.md" >}})Medium58.4%
0863All Nodes Distance K in Binary Tree[Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}})Medium62.3%
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%
0924Minimize Malware Spread[Go]({{< relref "/ChapterFour/0900~0999/0924.Minimize-Malware-Spread.md" >}})Hard42.1%
0928Minimize Malware Spread II[Go]({{< relref "/ChapterFour/0900~0999/0928.Minimize-Malware-Spread-II.md" >}})Hard42.8%
0938Range Sum of BST[Go]({{< relref "/ChapterFour/0900~0999/0938.Range-Sum-of-BST.md" >}})Easy85.9%
0947Most Stones Removed with Same Row or Column[Go]({{< relref "/ChapterFour/0900~0999/0947.Most-Stones-Removed-with-Same-Row-or-Column.md" >}})Medium58.9%
0959Regions Cut By Slashes[Go]({{< relref "/ChapterFour/0900~0999/0959.Regions-Cut-By-Slashes.md" >}})Medium69.1%
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" >}})Easy54.6%
1020Number of Enclaves[Go]({{< relref "/ChapterFour/1000~1099/1020.Number-of-Enclaves.md" >}})Medium65.6%
1022Sum of Root To Leaf Binary Numbers[Go]({{< relref "/ChapterFour/1000~1099/1022.Sum-of-Root-To-Leaf-Binary-Numbers.md" >}})Easy73.5%
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%
1034Coloring A Border[Go]({{< relref "/ChapterFour/1000~1099/1034.Coloring-A-Border.md" >}})Medium49.2%
1038Binary Search Tree to Greater Sum Tree[Go]({{< relref "/ChapterFour/1000~1099/1038.Binary-Search-Tree-to-Greater-Sum-Tree.md" >}})Medium85.5%
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%
1202Smallest String With Swaps[Go]({{< relref "/ChapterFour/1200~1299/1202.Smallest-String-With-Swaps.md" >}})Medium57.7%
1203Sort Items by Groups Respecting Dependencies[Go]({{< relref "/ChapterFour/1200~1299/1203.Sort-Items-by-Groups-Respecting-Dependencies.md" >}})Hard51.2%
1254Number of Closed Islands[Go]({{< relref "/ChapterFour/1200~1299/1254.Number-of-Closed-Islands.md" >}})Medium66.9%
1302Deepest Leaves Sum[Go]({{< relref "/ChapterFour/1300~1399/1302.Deepest-Leaves-Sum.md" >}})Medium86.6%
1305All Elements in Two Binary Search Trees[Go]({{< relref "/ChapterFour/1300~1399/1305.All-Elements-in-Two-Binary-Search-Trees.md" >}})Medium79.8%
1306Jump Game III[Go]({{< relref "/ChapterFour/1300~1399/1306.Jump-Game-III.md" >}})Medium63.5%
1319Number of Operations to Make Network Connected[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})Medium62.1%
1600Throne Inheritance[Go]({{< relref "/ChapterFour/1600~1699/1600.Throne-Inheritance.md" >}})Medium63.6%
1631Path With Minimum Effort[Go]({{< relref "/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort.md" >}})Medium55.7%
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.5%
------------------------------------------------------------------------------------------------------------------------------------------------

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