Dynamic Dynamic Programming (DDP): Heavy-Light Decomposition & Matrix Segment Trees on Trees

Dynamic DP (DDP) handles dynamic tree updates (such as node weight changes) while answering global queries (e.g. maximum independent set) in $O(log^2 N)$ time per modification. By decomposing trees into heavy chains and expressing transitions as tropical $(max, +)$ matrix multiplications, segment trees maintain chain products efficiently.

Ready to Master LeetCode Hard Patterns?

Get instant lifetime access to all 45 video lectures, interactive source code templates, and interview prep guides.

Enroll in Masterclass ($49)

Disclaimer: LeetCode is a registered trademark of LeetCode LLC. Our tutorials are independent educational guides developed by industry veterans and are not affiliated with LeetCode.