dsa1 min read
Diameter of Binary Tree — Tree DP Height Trick
Find the diameter (longest path between any two nodes) using a depth function that tracks the maximum path through each node.
Read →
webcoderspeed.com
5 articles
Find the diameter (longest path between any two nodes) using a depth function that tracks the maximum path through each node.
Maximize robbery from a tree-structured neighborhood where adjacent (parent-child) nodes cannot both be robbed.
Find minimum cameras to monitor all nodes using greedy bottom-up: prefer placing cameras at parents of uncovered leaves.
Find the maximum path sum in a binary tree where the path can start and end at any node.
Find the maximum sum of any BST subtree within a binary tree using post-order DFS returning subtree metadata.