Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Create a tree structure of the family.
Without deaths, the order of inheritance is simply a pre-order traversal of the tree.
Mark the dead family members tree nodes and don't include them in the final order.