Search
⌘K
Get Premium
Leetcode 742. Closest Leaf in a Binary Tree
Given a binary tree and a target node value, return the value of the nearest leaf measured by edge distance — you may move both down to children and up to parents. The core idea is to treat the tree as an undirected graph (or add parent pointers) and perform a BFS from the target to find the closest leaf.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.