Ezvor

742. Closest Leaf in a Binary Tree

MediumTree Preparing judge… LeetCode
TreeDepth-First SearchBreadth-First SearchBinary Tree

Hints

Hint 1
Convert the tree to a general graph, and do a breadth-first search. Alternatively, find the closest leaf for every node on the path from root to target.