Evaluates understanding of tree/graph data modeling, dynamic indexing, and consistency and concurrency control for maintaining aggregate subordinate counts under updates; Category/Domain: System Design.
You are given manager→direct-report relationships for an organization (an employee has at most one direct manager; the top-level employee has none). Build a data structure/service that supports:
Discuss the data model, algorithms, and how you would keep queries fast while handling updates safely (e.g., avoiding cycles).