Z29

Binary Tree Maximum Path Sum

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

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) -> int

Input & Output Contract

Output Rule:Maksimum yol toplamı tam sayısı.

System Constraints

1 <= agac.length <= 3 * 10^4
-1000 <= agac[i] <= 1000

Example Execution Walkthrough

agac = [1, 2, 3] -> 2 + 1 + 3 = 6
agac = [-10, 9, 20, None, None, 15, 7] -> 15 + 20 + 7 = 42

Example Test Scenarios (3)

Example 1
Input:[[1,2,3]]
Expected Output:6
Example 2: Köksüz Maksimum
Input:[[-10,9,20,null,null,15,7]]
Expected Output:42
Example 3: Tek Negatif
Input:[[-3]]
Expected Output:-3
Loading Python Editor...
Input Parameters
[
  [
    1,
    2,
    3
  ]
]
Expected Output
6