Graph Theory37 sections · 1633 units
Open in Course

CSES 1674 Subordinates - Lessons

Subtree aggregation

This problem shows the core pattern: define state (subtree size), write recurrence (sum children plus self), implement DFS. Many tree DP problems follow this exact structure. The only difference is what you aggregate (size, max, count, etc.).

If you can count subordinates, you can solve harder tree DP problems. The aggregation changes but the DFS pattern stays the same. This is your foundation. Every tree DP solution builds on this structure.