Question bank › Trees
Dsa Trees Easy

Sum of Left Leaves

Calculate the sum of all left leaves in a binary tree. A left leaf is a leaf node that is the left child of its parent. Input format: - The first line contains an integer N, the number of nodes in the tree. - The following N lines contain integers representing each node's value in level-order traversal. Use -1 to indicate 'null' nodes. Output format: - Print a single integer representing the sum of all left leaves. Example: Input: 5 1 2 3 -1 -1 4 -1 -1 Output: 2

Key concepts

treesleavessum

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.