11. Maximum Path Sum
β GFG solution to the Maximum Path Sum problem: find maximum sum path between any two nodes in a binary tree using recursive DFS technique. π
π§© Problem Description
π Examples
Example 1
Input: root[] = [10, 2, 10, 20, 1, N, -25, N, N, N, N, 3, 4]
Output: 42
Explanation: The maximum path sum is 20 + 2 + 10 + 10 = 42
(represented by green nodes in the tree).Example 2
Input: root[] = [-17, 11, 4, 20, -2, 10]
Output: 31
Explanation: The maximum path sum is 20 + 11 = 31
(represented by green nodes in the tree).π Constraints
β
My Approach
Recursive DFS
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated