Problem 742 · Medium

Closest Leaf in a Binary Tree

Breadth-first search outward from a target node, treating parent links as edges, until the first leaf appears.

Open the interactive visualisation