Easy · Trees
Sum of Nodes
Given the root of a binary tree, return the sum of all its node values, or 0 if the tree is empty.
Examples
Example 1
[1,2,3,4,5,6,7]Output: sum = 28
Example 2
[5,3,8,null,4,null,10]Output: sum = 30
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.