Key Sum Management

Problem Overview

  • Compute the final sum of all key values after applying a sequence of tree operations.
  • Input: an initial key tree with n nodes and q operations (1≤n,q≤1e5). Ro p v adds child v to parent p with v = current nodes+1, value 0. Re I z adds z to all nodes at level I and their descendants. Output: the total sum.
  • Context: key hierarchy where level equals number of parents; supports growth and bulk updates.
  • From Rubrik interviews; a data structures coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: