Hot100: Binary Tree Maximum Path Sum (Tree DP / Single-Side Gain ACERS Guide)

Subtitle / Summary The easiest way to get lost in LeetCode 124 is to make one recursive return value carry too much meaning. The stable design is to separate two roles: the recursion returns only the best single-side gain to the parent, while the full path through the current node is used to update the global maximum. Reading time: 12-15 min Tags: Hot100, binary tree, tree DP, DFS, postorder SEO keywords: Binary Tree Maximum Path Sum, tree DP, single-side gain, postorder, DFS, LeetCode 124 Meta description: Learn LeetCode 124 from the single-side gain invariant, global path update, and negative-branch pruning, with runnable multi-language implementations. A — Algorithm Problem Restatement A path in a binary tree is a sequence of nodes such that: ...

April 20, 2026 · 13 min · map[name:Jeanphilo]

Hot100: Diameter of Binary Tree (Tree DP / Height Return ACERS Guide)

Subtitle / Summary The most common confusion in LeetCode 543 is deciding what the recursive function should return. It should return height, not diameter. The diameter is updated globally at each node using leftHeight + rightHeight. Once that separation is clear, the problem becomes a clean introduction to tree DP. Reading time: 10-13 min Tags: Hot100, binary tree, tree DP, DFS, postorder SEO keywords: Diameter of Binary Tree, tree DP, height return, DFS, LeetCode 543 Meta description: Learn LeetCode 543 from the postorder height-return pattern, with step-by-step derivation, engineering analogies, and runnable multi-language solutions. A — Algorithm Problem Restatement Given the root root of a binary tree, return the diameter of the tree. ...

April 19, 2026 · 12 min · map[name:Jeanphilo]