#404
Sum of Left Leaves
pupil · 355 · lc easy +23 · verified · 62.4% accepted · 5,782 likes · top 64%
Description
Given the root of a binary tree, add up the values of all left leaves and return the total. A leaf is a node with no children; a left leaf is a leaf that is the left child of some other node.
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: 24
Explanation: There are two left leaves in the binary tree, with values 9 and 15 respectively.
Example 2:
Input: root = [1]
Output: 0
Code
1
2
3
4
5
6
7
8
9