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]