Greater sum tree
Your task
Given a binary search tree encoded as a level-order array (null for missing), convert it to a Greater Sum Tree where every node's new value is its original value plus the sum of all original values strictly greater than it. Return the result as a level-order array using the SAME shape as the input (null in the same positions), i.e. replace each non-null entry with its transformed value.
Examples
bst_to_greater_sum(level: list) -> listExample 1
Input
bst_to_greater_sum([4, 1, 6, 0, 2, 5, 7, None, None, None, 3, None, None, None, 8])Output
[30, 36, 21, 36, 35, 26, 15, None, None, None, 33, None, None, None, 8]