I have a wrong result submission here while I doubt whether it's correct.
I think it should be 1 + -2 + 3 =2
Anyone can help explain this please?
1 / \ -2 -3 / \ / 1  -2 / -1
Pay attention to this description 'The path may start and end at any node in the tree.' So tree root do not have to be in the maximum path.
I noticed that ... the last node is -1 instead of 1. so the max path sum should be 2 whether it cross tree root or not.
Thanks @yangyang. It's my bad. I have updated my answer. The path can only have one node.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.