Problem 2973 · Hard

Find Number of Coins to Place in Tree Nodes

Post-order DFS keeps subtree costs; a node with at least three subtree nodes gets the best triple product, clamped at zero.

Open the interactive visualisation