Problem 1443 · Medium

Minimum Time to Collect All Apples in a Tree

Each edge needed for an apple is walked twice, so a depth-first pass adds two seconds per edge whose subtree holds an apple.

Open the interactive visualisation