@navin
it is not necessary that path b/w two leaves always pass thru root.
On Wed, Aug 29, 2012 at 1:15 AM, Navin Gupta wrote:
> I think the path between two leaves always passes thru root.
> Now we can keep track of root-to-leaf path whose sum is max and secondMax
> among all sums.
> Now betwe
@navin :
/*
*I think the path between two leaves always passes thru root.*
*/
not alwayzz..consider a case where there are 2 leaf node on left side of
the tree.
1
/
5
/ \
10 15
ans :30 ( 5,10,15)
root(1) is not included.
On Wed, Aug 29, 2012 at 1:15 AM, Navin Gupta wrote:
>
I think the path between two leaves always passes thru root.
Now we can keep track of root-to-leaf path whose sum is max and secondMax
among all sums.
Now between this two leaves path, root is repeated.
Hence actual sum is maxsum + secondMaxSum - root->val;
This can be done by iterative inorder tr