Quant Memo
Coding/●●●●

Longest chain across a tree

The diameter of a binary tree is the length (in edges) of the longest path between any two nodes. That path need not pass through the root.

        1
       / \
      2   3
     / \
    4   5
-> 3        # the path 4 -> 2 -> 1 -> 3 has 3 edges

Return the diameter (edge count of the longest path).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions