Tree: root , left , right (left , right ). DFS leaf : returns . DFS leaf : returns . DFS node : leftMax , rightMax . Updates maxPath .
Returns . DFS leaf : returns . DFS root : leftMax , rightMax . Updates maxPath . Returns . Answer: .
Example tree trace
Tree: root , left , right (left , right ). DFS leaf : returns . DFS leaf : returns . DFS node : leftMax , rightMax . Updates maxPath .
Returns . DFS leaf : returns . DFS root : leftMax , rightMax . Updates maxPath . Returns . Answer: .