Meta logoMeta
Coding·40 minMembers

Tree Diameter / Longest Path

Members only

LeetCode 543 / 1245. Longest path between any two nodes in a tree. DFS returns the deepest descendant chain; at each node, the diameter candidate is the sum of the two longest child chains.

SWE
MLE
Infra Eng
tree
dfs
tree-traversal
medium
Frequency
Low
Last asked
2026-04-02
Stage
phone-screen · onsite-coding

Log in to continue reading the full content