Binary Search Tree to Greater Sum Tree
A medium-tier problem at 88% community acceptance, tagged with Tree, Depth-First Search, Binary Search Tree. Reported in interviews at eBay and 2 others.
You're staring at a BST and the problem asks you to convert it so each node holds the sum of itself plus all greater nodes. It sounds like a traversal tweak until you realize the standard left-right order is backwards. eBay, SAP, and Datadog ask this one. The trick isn't the algorithm, it's the traversal order. Most candidates solve it the hard way first. If you blank on the reversal during your live assessment, StealthCoder surfaces a working solution in seconds while the proctor sees nothing.
Companies that ask "Binary Search Tree to Greater Sum Tree"
Binary Search Tree to Greater Sum 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. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe naive approach: in-order traverse to collect all values, sort, compute prefix sums, then update the tree. That works but misses the elegant pattern. The real solution is a reverse in-order traversal (right-root-left instead of left-root-right) with a running sum. As you visit nodes from largest to smallest, each node's new value becomes the running total, which is then updated with that node's original value. The gotcha is realizing that BST properties let you visit nodes in descending order without sorting. Most candidates waste 10 minutes trying to do it in forward order. If this problem lands in your assessment and you freeze on the traversal direction, StealthCoder hands you the reverse-order template instantly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Binary Search Tree to Greater Sum Tree recycles across companies for a reason. It's medium-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. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Binary Search Tree to Greater Sum Tree interview FAQ
How hard is this problem really?+
Medium difficulty, but the acceptance rate is 88%, so the actual challenge is lower than you'd expect. The barrier is pattern recognition, not implementation complexity. Once you see the reverse in-order trick, coding it takes minutes.
Is this still asked at eBay, SAP, and Datadog?+
Yes. All three companies report it. It's the kind of tree problem big tech uses to separate candidates who know BST properties from those who just memorize standard traversals. The low acceptance rate isn't from failed submissions, it's from candidates not seeing the reversal.
What's the trick I'm missing?+
Reverse in-order traversal. Visit the right subtree first, then the node, then the left. Maintain a running sum as you go. That sum becomes each node's new value. It's not about sorting or extra data structures, it's about traversal order.
How does this relate to DFS and BST topics?+
It combines both. You're doing DFS (specifically, a modified in-order traversal), and you're leveraging the BST property that right subtree values are always greater. The problem tests whether you can adapt a standard traversal, not just execute it mechanically.
Will standard in-order traversal work?+
It'll get you values in ascending order. You'd need to either reverse them later or use extra space to track sums. The reverse in-order approach does it in one pass with O(1) extra space. It's the efficient pattern interviewers want to see.
Want the actual problem statement? View "Binary Search Tree to Greater Sum Tree" on LeetCode →