Back to course home
0% completed
Vote For New Content
Solution: Sum of Left Leaves
Problem Statement
Given the root of a binary tree, return the sum of all left leaves.
A leaf is a node that does not have any child nodes, and a left leaf is a leaf that is the left child of its parent.
Examples
Example 1:
- Input: root =
[3,5,10,null,null,8,7]
- Expected Output:
13 - Justification: The leaf nodes are
5,8, and7, but only5and8are left leaf nodes. So, sum of left leaf nodes are 5 + 8 = 13.
Example 2:
- Input: root =
[5, 3, 8, 2, 4, null, 6, 1]
- Expected Output:
1
.....
.....
.....
Like the course? Get enrolled and start learning!