Graph Theory37 sections · 1633 units
Open in Course

CSES 1674 Subordinates - Problem Statement

CSES 1674

You are given a company hierarchy as a tree. Each node represents an employee. Node 11 is the CEO. Edges represent direct reporting relationships. For each employee, count how many subordinates they have. A subordinate is anyone in their subtree, excluding the employee themselves.

This is a direct application of subtree size computation. If you can count nodes in a subtree, you can solve this. Compute sizes, then subtract one for each node.