Binary Tree Root to Leaf Path Sum Equal to a Given Number.
Given a binary tree and a sum, Determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
If path is found then return true else return false.
Note: What is leaf node? Any node whose left and right children is null is known as leaf node.
For example –
In this Binary tree, there exist a path from root-to-leaf node whose sum is equal to the given sum (which is 16).
Now, suppose if the given value of sum is 12. Then in this case we simply return false. As the root-to-leaf node path does not exist in a Binary tree whose sum is equal to 12.