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.
Each edge needed for an apple is walked twice, so a depth-first pass adds two seconds per edge whose subtree holds an apple.