This post is completed by 2 users
|
Add to List |
184. Get the Sum of all left leaves in a Binary tree
Objective: Given a binary tree, find the sum of all the nodes that are left as well as leaves nodes.
Example:
Approach:
- Do the inorder traversal
- check if the node is the left child and leaf node.
- If yes then add it to the sum.
- See the code for more understanding.
Output:
Sum of left leaves: 21