Find The Sum Of The Left Leaves Problem Statement
Given a binary tree with ‘root’, your task is to find and return the sum of all the left leaf nodes.
Example:
Input:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Output:
9
Explanation:
Node 4 and Node 5 are the left leaf nodes in the tree. Node 6 is a leaf node but not a left child. Therefore, the sum is 4 + 5 = 9.
Constraints:
1 ≤ T <= 10
1 ≤ N <= 1000
Where ‘T’ is the number of test cases. ‘N’ is the number of nodes in the binary tree.
- Time Limit: 1 sec
Note:
You do not need to print anything; this has already been taken care of. Just implement the function and return the answer.
Be the first one to answer
Add answer anonymously...
Top PayPal SDE-2 interview questions & answers
Popular interview questions of SDE-2
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app