My first instinct was memoization and I pitched an N-squared solution.
Use a post-order DFS to compute the minimum cost to disconnect each subtree from its leaves. At each node, compare the cost of cutting the edge to its parent versus cutting edges within its subtree, and return the minimum. The root's result is the sum of the minimum costs of its children.
Pro tip: Clarify edge cases upfront: what if the root is a leaf? What if edge weights are negative? Handling these shows thoroughness and prevents incorrect assumptions.
Ask about tree size, edge weight ranges (negative?), and whether the root can be a leaf. Confirm that cutting an edge disconnects the subtree below it.
For a node, define f(node) as the minimum cost to disconnect the subtree rooted at node from all its leaves, assuming the edge to its parent is not cut.
For a leaf, f(leaf) = 0. For an internal node, f(node) = min(edge_weight_to_parent, sum of f(child) for all children). This captures the choice of cutting the parent edge or cutting within the subtree.
Traverse the tree recursively, computing f for each node bottom-up. At the root, the answer is the sum of f(child) for all children (since the root has no parent edge).
Time complexity is O(n) as each node is visited once. Space is O(h) for recursion stack. Test with simple trees, skewed trees, and negative weights if allowed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.