Concepts2
⚙️AlgorithmIntermediate
DP on Trees
DP on trees is a technique that computes answers for each node by combining results from its children using a post-order DFS.
#tree dp#post-order dfs#rerooting+12
⚙️AlgorithmIntermediate
Tree Distances and Diameter
Tree diameter is the longest simple path in a tree and can be found with two BFS/DFS runs.
#tree diameter#tree center#eccentricity+12