D14
Trees
64 stations · 23hBinary tree traversals, views, LCA and path problems. 64 interview problems explained by codestorywithMIK (23h of video), grouped into 8 patterns such as Traversals (DFS / BFS), Height, Depth & Diameter, Root-to-Leaf Paths.
Start this line →- Traversals (DFS / BFS)22
- Height, Depth & Diameter5
- Root-to-Leaf Paths7
- LCA & Ancestors3
- Construction & Serialization6
- Tree Modification4
- Tree as Graph17
- General Recursion on Trees33
Traversals (DFS / BFS)
0 of 22 passed- Time Needed to Inform All EmployeesLC 1376 · 24:56MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Binary Tree Right Side ViewLC 199 · 10:45MediumGoogle · Amazon · +13 more companiesLeetCode ↗ (opens in a new tab)
- Check Completeness of a Binary Tree (BFS) - (Meta, Amazon) : Explanation ➕ Live CodingLC 958 · 12:51MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Check Completeness of a Binary Tree (DFS) - (Meta, Amazon) : Explanation ➕ Live CodingLC 958 · 12:19MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Longest ZigZag Path in a Binary Tree -LC 1372 · 25:12MediumAmazon · MicrosoftLeetCode ↗ (opens in a new tab)
- Maximum Width of Binary TreeLC 662 · 16:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Level Sum of a Binary TreeLC 1161 · 20:01MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Validate Binary Tree NodesLC 1361 · 24:42MediumGoogle · Meta · +1 more companiesLeetCode ↗ (opens in a new tab)
- Find Largest Value in Each Tree RowLC 515 · 22:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Binary Tree Inorder TraversalLC 94 · 15:14EasyGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Find Bottom Left Tree ValueLC 513 · 23:52MediumGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Reverse Odd Levels of Binary TreeLC 2415 · 35:14MediumGoogle · josh technologyLeetCode ↗ (opens in a new tab)
- Minimum Number of Operations to Sort a Binary Tree by LevelLC 2471 · 24:36MediumGoogle · Amazon · +1 more companiesLeetCode ↗ (opens in a new tab)
- Find Elements in a Contaminated Binary TreeLC 1261 · 13:03MediumGoogle · AmazonLeetCode ↗ (opens in a new tab)
- Recover a Tree From Preorder TraversalLC 1028 · 26:46HardGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
Height, Depth & Diameter
0 of 5 passed- Binary Tree Maximum Path Sum - (Google, Meta, Amazon, Flipkart) : Explanation ➕ Live CodingLC 124 · 26:35HardGoogle · Amazon · +22 more companiesLeetCode ↗ (opens in a new tab)
- Minimum Depth of Binary TreeLC 111 · 11:48EasyGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Diameter of Binary TreeLC 543 · 19:38EasyGoogle · Amazon · +18 more companiesLeetCode ↗ (opens in a new tab)
- Height of Binary Tree After Subtree Removal QueriesLC 2458 · 41:20HardGoogle · Meta · +1 more companiesLeetCode ↗ (opens in a new tab)
- Balanced Binary TreeLC 110 · 16:45EasyGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
Root-to-Leaf Paths
0 of 7 passed- Path Sum - (Amazon, Microsoft, Accolite, Adobe...) : Explanation + Live Coding 🧑🏻💻👩🏻💻LC 112 · 10:33EasyGoogle · Amazon · +7 more companiesLeetCode ↗ (opens in a new tab)
- Binary Tree Maximum Path Sum - (Google, Meta, Amazon, Flipkart) : Explanation ➕ Live CodingLC 124 · 26:35HardGoogle · Amazon · +22 more companiesLeetCode ↗ (opens in a new tab)
- Sum Root to Leaf NumbersLC 129 · 12:42MediumGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Sum of Root To Leaf Binary NumbersLC 1022 · 14:12EasyGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
LCA & Ancestors
0 of 3 passed- Lowest Common Ancestor of a Binary TreeLC 236 · 16:44MediumGoogle · Amazon · +20 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Difference Between Node and AncestorLC 1026 · 35:23MediumAmazon · Meta · +3 more companiesLeetCode ↗ (opens in a new tab)
- Lowest Common Ancestor of Deepest LeavesLC 1123 · 42:25MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
Construction & Serialization
0 of 6 passed- Create Binary Tree From DescriptionsLC 2196 · 19:14MediumGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Recover a Tree From Preorder TraversalLC 1028 · 26:46HardGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
Tree Modification
0 of 4 passed- Delete Nodes And Return Forest SolvedLC 1110 · 15:24MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Delete Leaves With a Given ValueLC 1325 · 12:42MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Flip Equivalent Binary TreesLC 951 · 23:43MediumGoogle · Amazon · +1 more companiesLeetCode ↗ (opens in a new tab)
Tree as Graph
0 of 17 passed- Time Needed to Inform All EmployeesLC 1376 · 24:56MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Check Completeness of a Binary Tree (BFS) - (Meta, Amazon) : Explanation ➕ Live CodingLC 958 · 12:51MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Check Completeness of a Binary Tree (DFS) - (Meta, Amazon) : Explanation ➕ Live CodingLC 958 · 12:19MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Width of Binary TreeLC 662 · 16:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Level Sum of a Binary TreeLC 1161 · 20:01MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- All Nodes Distance K in Binary TreeLC 863 · 21:59MediumGoogle · Amazon · +16 more companiesLeetCode ↗ (opens in a new tab)
- Validate Binary Tree NodesLC 1361 · 24:42MediumGoogle · Meta · +1 more companiesLeetCode ↗ (opens in a new tab)
- Find Largest Value in Each Tree RowLC 515 · 22:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Amount of Time for Binary Tree to Be InfectedLC 2385 · 29:25MediumGoogle · Amazon · +11 more companiesLeetCode ↗ (opens in a new tab)
- Amount of Time for Binary Tree to Be InfectedLC 2385 · 41:15MediumGoogle · Amazon · +11 more companiesLeetCode ↗ (opens in a new tab)
- Find Bottom Left Tree ValueLC 513 · 23:52MediumGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Reverse Odd Levels of Binary TreeLC 2415 · 35:14MediumGoogle · josh technologyLeetCode ↗ (opens in a new tab)
- Minimum Number of Operations to Sort a Binary Tree by LevelLC 2471 · 24:36MediumGoogle · Amazon · +1 more companiesLeetCode ↗ (opens in a new tab)
- Find Elements in a Contaminated Binary TreeLC 1261 · 13:03MediumGoogle · AmazonLeetCode ↗ (opens in a new tab)
General Recursion on Trees
0 of 33 passed- Time Needed to Inform All EmployeesLC 1376 · 24:56MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Find Leaves Of Binary TreeLC 366 · 17:45 · LeetCode PremiumMediumGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Binary Tree PruningLC 814 · 16:48MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Binary Tree Pruning (O(n))- (Google, Amazon, Microsoft) : Explanation + Live Coding 🧑🏻💻👩🏻💻LC 814 · 6:00MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Count Complete Tree Nodes -(Amazon, Microsoft, Salesforce, Meta) : Explanation ➕ Live CodingLC 222 · 21:36MediumGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Leaf-Similar TreesLC 872 · 8:08EasyGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Product of Splitted Binary TreeLC 1339 · 29:44MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Symmetric Tree (Leetcode - 101) - (Amazon, Microsoft, Mentor (Siemens)) : Explanation ➕ Live CodingLC 101 · 10:07EasyGoogle · Amazon · +9 more companiesLeetCode ↗ (opens in a new tab)
- Sum Root to Leaf NumbersLC 129 · 12:42MediumGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Width of Binary TreeLC 662 · 16:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Maximum Level Sum of a Binary TreeLC 1161 · 20:01MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Validate Binary Tree NodesLC 1361 · 24:42MediumGoogle · Meta · +1 more companiesLeetCode ↗ (opens in a new tab)
- Find Largest Value in Each Tree RowLC 515 · 22:53MediumGoogle · Amazon · +6 more companiesLeetCode ↗ (opens in a new tab)
- Count Nodes Equal to Average of SubtreeLC 2265 · 24:13MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Distribute Coins in Binary TreeLC 979 · 26:21MediumGoogle · Amazon · +5 more companiesLeetCode ↗ (opens in a new tab)
- Find Bottom Left Tree ValueLC 513 · 23:52MediumGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Smallest String Starting From LeafLC 988 · 25:37MediumGoogle · AmazonLeetCode ↗ (opens in a new tab)
- Delete Leaves With a Given ValueLC 1325 · 12:42MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Step-By-Step Directions From a Binary Tree Node to AnotherLC 2096 · 34:05MediumGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Number of Good Leaf Nodes PairsLC 1530 · 28:55MediumGoogle · TikTok · +1 more companiesLeetCode ↗ (opens in a new tab)
- Number of Good Leaf Nodes PairsLC 1530 · 31:30MediumGoogle · TikTok · +1 more companiesLeetCode ↗ (opens in a new tab)
- Linked List in Binary TreeLC 1367 · 20:58MediumGoogle · Amazon · +3 more companiesLeetCode ↗ (opens in a new tab)
- Height of Binary Tree After Subtree Removal QueriesLC 2458 · 41:20HardGoogle · Meta · +1 more companiesLeetCode ↗ (opens in a new tab)
- Reverse Odd Levels of Binary TreeLC 2415 · 35:14MediumGoogle · josh technologyLeetCode ↗ (opens in a new tab)
- Find Elements in a Contaminated Binary TreeLC 1261 · 13:03MediumGoogle · AmazonLeetCode ↗ (opens in a new tab)
- Lowest Common Ancestor of Deepest LeavesLC 1123 · 42:25MediumGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
- Sum of Left LeavesLC 404 · 19:49EasyGoogle · Amazon · +4 more companiesLeetCode ↗ (opens in a new tab)
- Sum of Root To Leaf Binary NumbersLC 1022 · 14:12EasyGoogle · Amazon · +2 more companiesLeetCode ↗ (opens in a new tab)
All 64 stations in order
- 1.Construct Quad Tree (Leetcode - 427) - (Google) : Explanation ➕ Live Coding (LeetCode 427)
- 2.Time Needed to Inform All Employees (LeetCode 1376)
- 3.Binary Tree Right Side View (LeetCode 199)
- 4.Binary Tree Right Side View (LeetCode 199)
- 5.Construct Binary Tree From Preorder And Inorder Traversal (LeetCode 105)
- 6.Lowest Common Ancestor of a Binary Tree (LeetCode 236)
- 7.Check Completeness of a Binary Tree (BFS) - (Meta, Amazon) : Explanation ➕ Live Coding (LeetCode 958)
- 8.Check Completeness of a Binary Tree (DFS) - (Meta, Amazon) : Explanation ➕ Live Coding (LeetCode 958)
- 9.Delete Nodes And Return Forest Solved (LeetCode 1110)
- 10.Find Leaves Of Binary Tree (LeetCode 366)
- 11.Binary Tree Pruning (LeetCode 814)
- 12.Binary Tree Pruning (O(n))- (Google, Amazon, Microsoft) : Explanation + Live Coding 🧑🏻💻👩🏻💻 (LeetCode 814)
- 13.Path Sum II (LeetCode 113)
- 14.Path Sum - (Amazon, Microsoft, Accolite, Adobe...) : Explanation + Live Coding 🧑🏻💻👩🏻💻 (LeetCode 112)
- 15.Add One Row to Tree (LeetCode 623)
- 16.Count Complete Tree Nodes -(Amazon, Microsoft, Salesforce, Meta) : Explanation ➕ Live Coding (LeetCode 222)
- 17.Leaf-Similar Trees (LeetCode 872)
- 18.Maximum Difference Between Node and Ancestor (LeetCode 1026)
- 19.Maximum Product of Splitted Binary Tree (LeetCode 1339)
- 20.Binary Tree Maximum Path Sum - (Google, Meta, Amazon, Flipkart) : Explanation ➕ Live Coding (LeetCode 124)
- 21.Binary Tree Preorder Traversal - (Microsoft, Walmart, Flipkart, Amazon) : Explanation ➕ Live Coding
- 22.Same Tree (LeetCode 100)
- 23.Find Duplicate Subtrees (Leetcode - 652) - (GOOGLE) : Explanation ➕ Live Coding (LeetCode 652)
- 24.Symmetric Tree (Leetcode - 101) - (Amazon, Microsoft, Mentor (Siemens)) : Explanation ➕ Live Coding (LeetCode 101)
- 25.Sum Root to Leaf Numbers (LeetCode 129)
- 26.Construct Binary Tree from Inorder and Postorder Traversal (LeetCode 106)
- 27.Longest ZigZag Path in a Binary Tree - (LeetCode 1372)
- 28.Maximum Width of Binary Tree (LeetCode 662)
- 29.Maximum Level Sum of a Binary Tree (LeetCode 1161)
- 30.Minimum Depth of Binary Tree (LeetCode 111)
- 31.All Nodes Distance K in Binary Tree (LeetCode 863)
- 32.Validate Binary Tree Nodes (LeetCode 1361)
- 33.Find Largest Value in Each Tree Row (LeetCode 515)
- 34.Count Nodes Equal to Average of Subtree (LeetCode 2265)
- 35.Binary Tree Inorder Traversal (LeetCode 94)
- 36.Amount of Time for Binary Tree to Be Infected (LeetCode 2385)
- 37.Amount of Time for Binary Tree to Be Infected (LeetCode 2385)
- 38.Distribute Coins in Binary Tree (LeetCode 979)
- 39.Paths from root with a specified sum
- 40.Pseudo-Palindromic Paths in a Binary Tree (LeetCode 1457)
- 41.Count the nodes at distance K from leaf
- 42.Diameter of Binary Tree (LeetCode 543)
- 43.Find Bottom Left Tree Value (LeetCode 513)
- 44.Even Odd Tree (LeetCode 1609)
- 45.Smallest String Starting From Leaf (LeetCode 988)
- 46.Delete Leaves With a Given Value (LeetCode 1325)
- 47.Create Binary Tree From Descriptions (LeetCode 2196)
- 48.Step-By-Step Directions From a Binary Tree Node to Another (LeetCode 2096)
- 49.Number of Good Leaf Nodes Pairs (LeetCode 1530)
- 50.Number of Good Leaf Nodes Pairs (LeetCode 1530)
- 51.Linked List in Binary Tree (LeetCode 1367)
- 52.Cousins in Binary Tree II (LeetCode 2641)
- 53.Flip Equivalent Binary Trees (LeetCode 951)
- 54.Height of Binary Tree After Subtree Removal Queries (LeetCode 2458)
- 55.Reverse Odd Levels of Binary Tree (LeetCode 2415)
- 56.Minimum Number of Operations to Sort a Binary Tree by Level (LeetCode 2471)
- 57.Find Elements in a Contaminated Binary Tree (LeetCode 1261)
- 58.Recover a Tree From Preorder Traversal (LeetCode 1028)
- 59.Construct Binary Tree from Preorder and Postorder Traversal (LeetCode 889)
- 60.Lowest Common Ancestor of Deepest Leaves (LeetCode 1123)
- 61.Sum of Left Leaves (LeetCode 404)
- 62.Evaluate Boolean Binary Tree (LeetCode 2331)
- 63.Balanced Binary Tree (LeetCode 110)
- 64.Sum of Root To Leaf Binary Numbers (LeetCode 1022)