Loading problem…
Given the root of a nonempty binary tree, return the largest sum of values on a nonempty path.
A path follows parent-child edges and may start and end at any nodes. It does not have to pass through the root. No node may be visited twice.
Example inputs use level-order arrays with null for a missing child. Your function receives a TreeNode object with val, left, and right fields.
Example 1:
Example 2:
Example 3: