Search
⌘K

Leetcode 1443. Minimum Time to Collect All Apples in a Tree

Given a tree rooted at 0 with some nodes containing apples, find the minimum seconds (1 per edge traversal) to start at 0, collect all apples, and return to 0 — equivalently sum 2× each edge that lies on any path to an apple, which can be found by a post-order DFS that prunes subtrees without apples. (n up to 1e5.)

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late September, 2025

Meta

Mid-level

Late July, 2025

Meta

Senior

Early April, 2025

Meta

Mid-level

Comments

Your account is free and you can post anonymously if you choose.