shlogg · Early preview
Md Ariful Haque @mah-shamim

Binary Search Tree To Greater Sum Tree Conversion

Convert BST to Greater Sum Tree: traverse right subtree first, update node value with prefix sum, and recursively process left subtree.

1038. Binary Search Tree to Greater Sum Tree
Difficulty: Medium
Topics: Tree, Depth-First Search, Binary Search Tree, Binary Tree
Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.
As a reminder, a binary search tree is a tree that satisfies these constraints:

The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys greater than the node's key.
Both the l...