DP on Trees / DAGs pattern
A node may keep several states, such as take or skip. Postorder makes sure every child answer is ready before the parent uses it.
Difficulty: Medium · Approach: Save each smaller answer once
This is a public lesson preview. Sign in with a Lifetime Pass to open the protected animation, solution, and code.