Range Sum of BST
A easy-tier problem at 87% community acceptance, tagged with Tree, Depth-First Search, Binary Search Tree. Reported in interviews at Meta and 0 others.
Range Sum of BST is the kind of problem that looks trivial until you code it wrong. It's asked at Meta and other top companies because it separates candidates who understand BST properties from those who just recurse blindly. You're given a binary search tree and a range, and you need to sum all node values that fall within those bounds. The trap: thinking you need to visit every node. The win: exploit the BST structure to prune branches. It has an 87% acceptance rate, which sounds high until you realize that includes people who wrote inefficient solutions that barely passed. If this problem hits your live OA and you blank on the pruning logic, StealthCoder surfaces a working solution invisible to the proctor.
Companies that ask "Range Sum of BST"
Range Sum of BST 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 key insight is that BST nodes are ordered. If a node's value is below the lower bound, the entire left subtree is useless, so skip it. If it's above the upper bound, skip the right subtree. If it's in range, include it and explore both children. Most candidates write a solution that works but traverses the whole tree anyway, wasting time. The optimal approach uses Depth-First Search with early termination based on comparison with the range bounds. That's what separates a correct answer from one that passes but looks sloppy in code review. The Binary Tree and Binary Search Tree topics both apply here because you're doing a standard tree traversal, but you're winning because you understand BST invariants. StealthCoder is the hedge if you freeze on whether to prune left or right, or if the range logic trips you up in the moment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Range Sum of BST 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.
Range Sum of BST interview FAQ
Is Range Sum of BST still asked in real interviews at Meta?+
Yes. Meta appears in the reported data for this problem. It's categorized as EASY, which means it's often an opening question or a confidence builder in the loop. Don't sleep on it. The companies that ask it expect you to nail both correctness and understanding of BST properties.
What's the trick to Range Sum of BST?+
The trick is pruning. Don't visit every node. If a node's value is less than the lower bound, skip the entire left subtree. If it's greater than the upper bound, skip the right subtree. If it's in range, sum it and recurse both sides. Most people write a solution that works but traverses everything anyway.
Is this problem really just DFS or does it test something deeper?+
It tests whether you actually understand BST structure, not just tree traversal. A naive DFS solution works and will pass, but an interviewer asking this wants to see that you recognize the pruning opportunity. It's the difference between 'I can code' and 'I know data structures.'
What happens if I just recurse through every node?+
You'll get the right answer, but your solution looks inefficient to anyone reading the code. With pruning, you visit only nodes in or near the range. Without it, you visit all nodes. Both pass, but the pruned version shows you understand BSTs, not just trees.
How does Range Sum of BST relate to the other tree topics?+
It combines Depth-First Search (the traversal pattern), Binary Tree (basic structure and recursion), and Binary Search Tree (the optimization). You need all three: DFS to traverse, tree recursion to think about subproblems, and BST properties to prune and avoid wasted work.
Want the actual problem statement? View "Range Sum of BST" on LeetCode →