Challenge: Sum of All Nodes in a Binary Tree

Let’s calculate the sum of the values present in the binary tree.


Given a binary tree, find the sum of values of all its nodes.


A binary tree.


Sum of values of all the nodes.

Sample input

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.