Concept Flow - DP on Trees Maximum Path Sum
Start at root node
Recursively find max path sum from left subtree
Recursively find max path sum from right subtree
Calculate max path through current node: left + node + right
Update global max if current path is higher
Return max path sum including current node and one subtree
Repeat for all nodes
Final max path sum stored globally
We start from the root and recursively find the max path sums from left and right subtrees. At each node, we calculate the max path sum passing through it and update the global max. We return the max sum including the node and one subtree to parent.
