Maximum path sum with Tree parsing | Interview DSA Learning


Maximum path sum

Difficulty: MediumAccuracy: 42.92%Submissions: 110K+Points: 4Average Time: 45m

Given the root of a binary tree, your task is to find the maximum path sum. The path may start and end at any node in the tree.

Examples:

Input: root[] = [10, 2, 10, 20, 1, N, -25, N, N, N, N, 3, 4]
Output: 42
Explanation: Max path sum is represented using green colour nodes in the above binary tree.

Input: root[] = [-17, 11, 4, 20, -2, 10]
Output: 31
Explanation: Max path sum is represented using green colour nodes in the above binary tree.

Constraints:
1 ≤ number of nodes ≤ 103
-104 ≤ node->data ≤ 104

Expected Complexities
Topic Tags
Related Interview Experiences
Related Articles
If you are facing any issue on this page. Please let us know.

Comments

Popular Posts