Elephant Tree
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
wheren
is the number of nodes inroot
https://binarysearch.com/problems/Elephant-Tree
Examples
Example 1
Input
- root =
Output
- answer =
Leave a comment