Sum of Left Leaves

Posted on



Find the sum of all left leaves in a given binary tree.


/ \
9 20
/ \
15 7

There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.


For tree traversal, think in recursion way first. The point is to catch the left leaves. So the base case  includes catching a left leaf. Then just recursively call itself on both left subtree and right subtree to find all the left leaves.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s