Validate Binary Search Tree
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Bloomberg reportedly asked candidates to validate a binary search tree in November 2025, and the problem boils down to one idea: every node lives inside a range set by all of its ancestors, not just its parent. If you've got an OA invite and 48 hours, this is a good one to lock in. It's short, it's a classic, and the trap is subtle enough to burn people who think they know it. Know the bounds trick and you're done in ten minutes. StealthCoder sits invisibly on your screen during the live OA as a safety net if you blank on the details.
The problem
Return whether the binary tree is a valid binary search tree. Every value in a left subtree must be strictly smaller than its ancestor, and every value in a right subtree must be strictly larger. Function isValidBST(root: TreeNode) → boolean Examples Example 1 root = [2,1,3] return = true Both children satisfy the strict bounds imposed by the root. Constraints The tree contains between 1 and 10000 nodes. Node values fit in a signed 32-bit integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to pass a lower and upper bound down the recursion. Start with negative infinity and positive infinity. Going left, the current value becomes the new upper bound. Going right, it becomes the new lower bound. Each node must satisfy lower < val < upper, strictly. The common pitfall is only comparing a node to its direct children. That passes a tree like [5,1,6,null,null,3,7], where 3 sits in the right subtree of 5 but is smaller than 5. Second pitfall: values fit in a signed 32-bit integer, so seeding bounds with INT_MIN and INT_MAX breaks on edge values. Use null or long bounds instead. Duplicates are invalid because the comparison is strict. An in-order traversal that checks strictly increasing values also works. Both run in O(n) time. If you freeze live, StealthCoder can hand you the bounded recursion while you keep your head straight.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Validate Binary Search 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as validate binary search tree. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Validate Binary Search Tree FAQ
What's the trick in Validate Binary Search Tree?+
Carry a valid range down the recursion. Each node must be strictly greater than the lower bound and strictly less than the upper bound. Going left tightens the upper bound to the current value. Going right tightens the lower bound. Checking only parent and child is the classic wrong answer.
How hard is this really for a Bloomberg OA?+
Medium on paper, easy if you've seen it. The logic is about ten lines. People fail on the edge cases: duplicates, extreme 32-bit values, and comparing only immediate children. Handle those and it's a quick solve.
Why does INT_MIN as a starting bound break?+
Node values can equal the minimum or maximum 32-bit integer. If you seed bounds with those values and use strict comparison, a valid node holding that value gets rejected. Use null bounds or a wider type like long so every legal value passes the initial check.
Can I use in-order traversal instead?+
Yes. An in-order walk of a valid BST produces strictly increasing values. Track the previously visited value and return false if the current one is less than or equal to it. It's O(n) time and equally accepted. Pick whichever you can write without bugs under pressure.
How do I prepare for this in 48 hours?+
Write the bounded recursion from scratch twice without notes. Then test it on a tree with a deep violation, a duplicate value, and a single node. Also write the in-order version as a backup. That covers nearly every variation of this problem you could see.