Fill a second tree with subtree sums of the first

0
Remix

You get the roots of two complete binary trees with exactly the same shape. For every node of the second tree, set its value to the sum of the subtree rooted at the matching node of the first tree. Walk both trees together in one post-order pass, and state the time and space it takes.

SnowflakeTechnical phone screenLast asked Sep 2025
No answer yet. Write the first one; the best answer gets endorsed.