The Second Minimum Node In a Binary Tree interview question gives you a special binary tree where every node satisfies: the node's value is the minimum of its subtree, and each node has exactly 0 or 2 children. The root holds the global minimum. Given such a tree, find the second minimum value in the entire tree. If no second minimum exists, return -1.
Meta and LinkedIn ask this tree problem because it requires reasoning about structural invariants — not just doing a generic traversal. Since every node's value is the minimum of its subtree, the second minimum must be found in subtrees that differ from the root's value. It tests whether candidates can prune recursive exploration intelligently using problem-specific constraints rather than brute-force DFS.
The pattern is pruning DFS on a special tree. Perform DFS from the root. At each node, if the node's value is greater than the root value, this node itself is a candidate for the second minimum (return it). If the node's value equals the root value, the second minimum might be deeper in either subtree — recurse into both children. When recursing, take the minimum of valid (non -1) results from left and right subtrees. Base case: if the node is null, return -1.
Tree:
2
/ \
2 5
/ \
2 7
Root value = 2 (global minimum).
DFS:
Second minimum: 5.
For the Second Minimum Node In a Binary Tree coding problem, the DFS binary tree interview pattern with pruning is the approach. The pruning condition is key: once you find a value greater than root, don't recurse further into that subtree. Meta interviewers appreciate when you explain why the structural property guarantees this pruning is safe. Practice this pattern — it generalizes to other problems where tree structure provides early termination opportunities.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Sum of Root To Leaf Binary Numbers | Easy | Solve | |
| Leaf-Similar Trees | Easy | Solve | |
| Diameter of Binary Tree | Easy | Solve | |
| Balanced Binary Tree | Easy | Solve | |
| Binary Tree Tilt | Easy | Solve |