Graph Theory37 sections · 1633 units
Open in Course

LeetCode 337 House Robber III - Lessons

Include/exclude on trees

This pattern appears whenever you have constraints like "cannot pick adjacent nodes" or "cannot select parent and child." The core idea: track both possibilities (include and exclude) for each node. Combine child values based on the constraint. You will see this in maximum independent set, vertex cover, tree matching, and many other tree improvement problems.

The structure is always the same: two states, different transitions.