Best Bending Path Sum in a Binary Tree

Asked at ByteDance · Coding Questions · Difficulty: Hard · Last asked Jan 26, 2026

Each node of a binary tree holds an integer value, possibly negative. A path is a sequence of nodes in which each consecutive pair is joined by a parent-child edge and no node appears twice. A path may start and end at any nodes and does not have to pass through the root. Its sum is the total of the values on it. Find the largest possible path sum, and then recover a path that achieves it.

Loading the problem…