← All problems
Binary Tree Maximum Path Sum
Find the maximum path sum in a binary tree, where a path is any sequence of nodes connected by parent-child edges and may start and end at any nodes. Node values may be negative.
Complexity
Time O(n), Space O(h)
Common pitfalls
- Allowing negative contributions downward (clamp at 0)
- Confusing return value with global answer
Your solution
Log in to save your code and track progress.