0742. Closest Leaf in a Binary Tree
Last updated
Last updated
**Input:** root = [1,3,2], k = 1
**Output:** 2
**Explanation:** Either 2 or 3 is the nearest leaf node to the target of 1.**Input:** root = [1], k = 1
**Output:** 1
**Explanation:** The nearest leaf node is the root node itself.**Input:** root = [1,2,3,4,null,null,null,5,null,6], k = 2
**Output:** 3
**Explanation:** The leaf node with value 3 (and not the leaf node with value 6) is nearest to the node with value 2.