← Samsung questions

Distance to the closest leaf from a target node in a binary tree

Filed under Samsung

Given a binary tree and the value of a target node, determine the minimum path distance to the nearest leaf node in the tree. Return 0 if the target node itself is a leaf, and return -1 if the target…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Samsung questions

Collected from public candidate posts and coding forums. Updated Nov 2026.