##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
You've done DP on arrays and grids. Trees add a new dimension: states live at nodes, not indices.
Perfect intro to tree DP state propagation
Classic rerooting technique for all nodes
Children before parents
Covered with full walkthrough in this section.
Covered with full walkthrough in this section.
Classic rerooting DP. Find node minimizing edge reversals to reach all others.
Count vertex pairs at distance k. Fundamental tree DP with path counting.
Maximize sum of subtree sizes during traversal. Beautiful rerooting application.
Maximize weighted distance sum from chosen root. Rerooting with contribution analysis.
Choose 3 nodes maximizing covered edges. Tree diameter extension problem.
Max path value with node values and edge costs. Tree path DP with pruning.
Max sum path in binary tree. Classic interview problem teaching path vs subtree distinction.
Minimum cameras to monitor all nodes. Tree DP with 3 states per node.
Longest path with constraint on adjacent nodes. Tree DP combining two best children.
Find diameter using interactive queries. Tree structure deduction.
Find max non-overlapping segments with equal sums. Greedy + interval selection.
Choose k components maximizing average sum. Tree DP with greedy selection.
Count independent sets on a tree - foundational tree DP with take/skip pattern.
Paint subtrees black with constraints - teaches rerooting technique for all-nodes answers.