Z29
Binary Tree Maximum Path Sum
Problem Statement & Objective
A path in a binary tree is a sequence of nodes where each pair of adjacent nodes has an edge. Return the maximum path sum of any non-empty path.
Function Signature (Python)
binary_tree_maximum_path_sum(root: list) -> intInput & Output Contract
Output Rule:Maksimum yol toplamı tam sayısı.
System Constraints
1 <= agac.length <= 3 * 10^4
-1000 <= agac[i] <= 1000Example Execution Walkthrough
agac = [1, 2, 3] -> 2 + 1 + 3 = 6
agac = [-10, 9, 20, None, None, 15, 7] -> 15 + 20 + 7 = 42Example Test Scenarios (3)
Example 1
Input:
[[1,2,3]]Expected Output:
6Example 2: Köksüz Maksimum
Input:
[[-10,9,20,null,null,15,7]]Expected Output:
42Example 3: Tek Negatif
Input:
[[-3]]Expected Output:
-3