NumPy allowed · plain Python earns 10 bonus points
Implement Binary Tree Maximum Path Sum -- one of the most-cited "hard" tree problems, requiring you to track two DIFFERENT quantities at each node: the best path usable by an ancestor (one-sided) vs. the best path THROUGH this node (both sides, only valid as a final answer here).
Implement max_path_sum(root): for each node, compute the best "downward" gain from each child (clamped to 0, since a negative-sum branch should just be excluded rather than dragging the total down), use both children's gains together to update a global best (a path bending through this node), but RETURN to the caller only this node's value plus the better of its two one-sided child gains (since a path continuing upward through an ancestor can only use one branch, not both).
max_path_sum(root: dict) -> int