Second Minimum Node In a Binary Tree
A easy-tier problem at 45% community acceptance, tagged with Tree, Depth-First Search, Binary Tree. Reported in interviews at LinkedIn and 0 others.
You're given a binary tree where every non-leaf node has exactly two children, and you need to find the second minimum value. It sounds simple until you realize the tree structure matters more than the values themselves. LinkedIn has asked this. The acceptance rate is below 46%, which means candidates are either overcomplicating it or missing the constraint that makes it solvable. If this lands in your OA and you freeze on the traversal logic, StealthCoder runs invisibly and surfaces the working solution in seconds.
Companies that ask "Second Minimum Node In a Binary Tree"
Second Minimum Node In a Binary Tree is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trick is understanding that in a tree where every non-leaf node has two children, the minimum value is always at the root. Once you know that, the second minimum is the smallest value you find that's strictly greater than the root. Most candidates try BFS or build a full sorted set, wasting time and memory. The efficient path uses depth-first search to traverse once, tracking the minimum and the second minimum as you go. You don't need to visit every node; prune branches where the current node equals the root, because nothing smaller or different can exist below it. This is where the tree structure earns its keep. If you hit this live and the obvious approach feels heavy, StealthCoder cuts through the noise and shows you the pruned DFS pattern.
Pattern tags
You know the problem.
Make sure you actually pass it.
Second Minimum Node In a Binary Tree recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Second Minimum Node In a Binary Tree interview FAQ
Why is the acceptance rate so low on an Easy problem?+
Candidates often miss the constraint that every non-leaf node has exactly two children. That constraint is the key to pruning the search space. Without recognizing it, the problem feels ambiguous and you over-engineer the solution. Understanding the tree shape is half the battle.
What's the difference between this and finding the kth smallest value?+
This problem is simpler because the second minimum has a fixed definition: the smallest value that's strictly greater than the root. You're not sorting or comparing arbitrary positions. DFS with early termination handles it in one pass. The constraint on tree structure makes pruning possible.
Should I use BFS or DFS?+
DFS is cleaner here. You recurse down left and right subtrees, and you can prune branches where the node value equals the root. There's no benefit to level-order traversal, and BFS uses more memory. A recursive DFS solution is both shorter and faster in practice.
What happens if there's no second minimum?+
If all non-leaf nodes have the same value as the root, then there's no distinct second minimum. The problem typically returns -1 in that case. Check the problem statement, but assume you need to handle the case where the second minimum doesn't exist.
How does this relate to other tree problems on interviews?+
It's a stepping stone to harder tree-search problems. The core skill is recognizing when a tree structure lets you prune the search space. Once you see that pattern here, you'll spot it in problems involving target sums, paths, and balanced trees.
Want the actual problem statement? View "Second Minimum Node In a Binary Tree" on LeetCode →