This post is completed by 2 users

  • 1
Add to List
Beginner

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:

Get the Sum of all left leaves in a Binary tree.

Approach:

  1. Do the inorder traversal
  2. check if the node is the left child and leaf node.
  3. If yes then add it to the sum.
  4. See the code for more understanding.

Output:

Sum of left leaves: 21