Dsa
Trees
Hard
Max Path Sum in Tree
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. The input consists of n lines containing integer values of the nodes. The output must be a single integer representing the maximum path sum.
Example:
Input:
4
-10
9
20
15
Output:
42
Key concepts
treesdynamic-programmingrecursion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now