← Questions

Throne inheritance without an initial king

0
SnowflakeCodingLast asked Sep 2026

Model a royal family's line of succession: people are born to parents, people die, and you return the current order of inheritance (a pre-order walk of the family tree that skips the dead). This is the classic throne-inheritance design, with a twist: the constructor does not give you a king, so the structure must start empty and decide who the root is as people are added.

Explain how the twist changes your data structures and edge cases.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding