Back to course home
0% completed
Deepest Leaves Sum (medium)
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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible