Coding Challenge

Binary Tree Maximum Path Sum

Hard
treedfs

Find the maximum path sum anywhere in a binary tree.

A path may start and end at any nodes but must follow parent-child links. Return the maximum path sum.

Examples

Input: root = [1,2,3]

Output: 6

Constraints

  • Nodes may contain negative values

Preparing your coding workspace...