Tree Sum
Given a binary tree root
, return the sum of all values in the tree.
Constraints
n ≤ 100,000
wheren
is the number of nodes inroot
https://binarysearch.com/problems/Tree-Sum
Examples
Example 1
Input
- root =
Output
- answer =
11
Explanation
11 = 1 + 2 + 3 + 5
Example 2
Input
- root =
Output
- answer =
6
Explanation
6 = 1 + 2 + 3
Leave a comment