DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Sum of Its Parts

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 3D modeling tool stores each design as an assembly tree: every component carries a `name`, a `quantity` (how many of it appear inside its parent, defaulting to 1 when absent), and a `children` list of sub-components nested arbitrarily deep. Roll the tree up into the total count of each leaf part (a component with no children, including one whose `children` list is empty), where a part's count is the product of the quantities along the path from the root down to it, added up across every place that part appears.

Summary

Every assembly hides smaller ones. Count what it really takes to build.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons