Thursday, April 24, 2014

Find the path along a binary tree where their node sums to a given value

Solution:
Key point is to know that the path is at most the height of the tree. Hence, need to find the height to the tree first.
Then use a path array to store the node value along the path
Then use recursive to go left and right to see whether we can find the sum and check sum at each point of the path

No comments:

Post a Comment