Back to course home
0% completed
Vote For New Content
Solution: Deepest Leaves Sum
Problem Statement
Given a root node of the binary tree, return the sum of all values located at the deepest leaves of a binary tree.
Examples
- Example 1:
- Input: root =
[1,2,3,4,5,null,7]
- Input: root =
-
Expected Output:
16 -
Justification: The deepest level contains the nodes with values 4, 5, and 7, and their sum is 16.
-
Example 2:
- Input: root =
[6,2,8,null,null,7,9,null,null,null,10]
- Input: root =
- Expected Output:
10- Justification: The deepest level contains only one node with the value 10, thus the sum is 10.
.....
.....
.....
Like the course? Get enrolled and start learning!