less than 1 minute read

Given a binary tree root, return the same tree except every node’s value is replaced by its original value plus all of the sums of its left and right subtrees.

Constraints

  • n ≤ 100,000 where n is the number of nodes in root

https://binarysearch.com/problems/Elephant-Tree

Examples

Example 1

Input

  • root =

Output

  • answer =

Solution

Leave a comment