Everything Beneath
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- mid
Problem
A life-sciences CRM stores customer accounts in a hierarchy: each record names its account `id`, the `parent` account it sits under (`None` for a top-level account), and the `sales` booked directly to it. For every account, report the combined sales of that account together with all the accounts below it, anywhere down the chain. Accounts with no children contribute only their own sales, and the records may describe several independent top-level accounts.
Summary
Every account carries the weight of all it contains.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.