Available question text
Given a rooted tree (parent array) where you can build a room only after its parent and you can move only along already-built edges, count the number of valid build orders to construct all rooms modulo 1e9+7. This reduces to computing how to interleave builds of each node's child subtrees — the answer is the product of multinomial coefficients based on subtree sizes, computable via a DFS with precomputed factorials/inverses.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1916. Count Ways to Build Rooms in an Ant Colony
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source