Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1916. Count Ways to Build Rooms in an Ant Colony
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.