Get the Sum of all left leaves in a Binary tree
Objective: Given a binary tree, find the sum of all the nodes which are left as well as leaves nodes.
- Approach is quite simple.
- Do the inorder traversal
- check if node if the left child and leaf node.
- If yes then add it to the sum.
- See the code for more understanding.
Sum of left leaves: 21
Top Companies Interview Questions..-
If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.