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 traversal of tehe tree

T[n] - o[n]
Space - o[n]

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/5Okg0EjlIAkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to