NumPy allowed · plain Python earns 10 bonus points
Implement Diameter of Binary Tree -- the classic "compute a global answer while also computing a per-node height" problem, solved in one pass by updating a running best as a side effect of the height recursion.
Implement diameter_of_binary_tree(root): while computing each node's height (for the return value), also update a running "best diameter seen so far" using that node's left-height + right-height (the longest path THROUGH this node).
diameter_of_binary_tree(root: dict | None) -> int