Second Minimum in a Tournament Tree
Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
LinkedIn reported this one in September 2026, and it looks like a tree problem until you notice what it really reduces to: find the second-smallest value among leaves, where the root already hands you the smallest. If the OA invite is sitting in your inbox, this is the kind of question that rewards five minutes of thinking over thirty minutes of typing. The tournament structure is the whole trick. The champion's path is the only place the runner-up can hide. StealthCoder is the safety net if you blank mid-assessment, but you can probably get this one yourself.
The problem
You are given the root of a tournament tree. Every node has either zero or two children, and each internal node stores the smaller value of its two children. All leaf values are distinct, and the tree has at least two leaves. Return the second-smallest leaf value. Function secondMin(root: TreeNode) → int Examples Example 1 root = [2,2,3,4,2,5,3] return = 3 The smallest leaf is 2, and 3 is the next smallest leaf. Example 2 root = [1,1,2,1,7,null,null,1,4] return = 2 The minimum winner travels through a deep full-tree chain; the next leaf value is 2. Example 3 root = [-5,-5,0,-5,-2,0,3] return = -2 Negative values obey the same tournament invariant, so -2 is second. Constraints The tree contains between 3 and 10001 nodes. Every node has either zero or two children. For every internal node, node.val = min(node.left.val, node.right.val). All leaf values are distinct. -1000000000 ≤ node.val ≤ 1000000000 The tree contains at least two leaves, so the answer always exists.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The root value is the global minimum, since each internal node stores the min of its children. The second minimum must have lost directly to the champion at some node along the champion's path. So walk down from the root. At each internal node, one child equals the root value (the winner side) and the other is the loser. Go into the winner child and record the loser child's value. Take the smallest recorded loser. Since a loser subtree's value is its own minimum, you don't need to descend into it. That's O(h) time, which is great for deep trees. The common pitfall is traversing every leaf, which works but misses the point. Another trap is the tie on values: leaves are distinct, but internal nodes repeat the champion value, so compare with the root value carefully. If the live OA freezes your brain, StealthCoder can supply the path-walk solution while you stay calm.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Second Minimum in a Tournament Tree cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass LinkedIn's OA.
LinkedIn reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Second Minimum in a Tournament Tree FAQ
What's the trick in Second Minimum in a Tournament Tree?+
The runner-up must have lost directly to the overall winner. So follow the champion's path from the root down, and at each step look at the sibling that didn't carry the winning value. The smallest of those siblings is your answer. You never need to scan the whole tree.
Can I just collect all leaves and sort them?+
Yes, it's correct. Gather the leaf values, then take the second smallest, or track the two smallest in one pass. It's O(n), which fits up to 10001 nodes easily. The path-walk is cleaner and faster on deep trees, but the brute approach is a safe fallback.
How hard is this problem really?+
Easy to medium. The code is short, but you need to see the invariant that each internal node equals the min of its children. Once you see it, it's about ten lines. Candidates who miss the invariant tend to overbuild with heaps or full traversals.
What edge cases should I test?+
Test the minimum three-node tree, negative values like Example 3, and a skewed deep tree where the champion runs down one side. Also check that you compare against the root value when deciding which child is the winner, since internal nodes repeat that value.
How do I prepare for this in 48 hours?+
Write the recursive and iterative versions of the path walk once each. Then practice reading tree invariants from constraints, since the key insight is hidden in the node.val = min(children) line. Run the three given examples by hand before submitting.