Code Room
CodingMediumcod-g765
Subject Binary search treeLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Implement
bst_to_greater_sum(level: list) → list
Examples
in[[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]]out[30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.