Sum of Left Leaves

Easy
Trees Tree DFS

Find sum of all left leaves in a binary tree given as level-order.

Constraints

Nodes ≤ 1000

Examples

Example 1:
Input: 3 9 20 null null 15 7
Output: 24
Explanation: Left leaves: 9 and 15
Example 2:
Input: 1
Output: 0
▲ Console
📱

Install Talent Enrich

Get instant access to jobs and career tools on your device.