Z33
Maximum Product of Splitted Binary Tree
Problem Statement & Objective
Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.
Function Signature (Python)
maximum_product_of_splitted_binary(root: list) -> intInput & Output Contract
Output Rule:Maksimum çarpım mod 1_000_000_007.
System Constraints
2 <= agac.length <= 5 * 10^4
1 <= agac[i] <= 10^4Example Execution Walkthrough
agac = [1, 2, 3, 4, 5, 6]
toplam = 21
1-2 kenarı silinirse: alt ağaç [2, 4, 5] toplamı 11, kalanı 10 -> 11 * 10 = 110Example Test Scenarios (3)
Example 1
Input:
[[1,2,3,4,5,6]]Expected Output:
110Example 2: 6 * 4 = 24
Input:
[[1,null,2,null,null,3,4]]Expected Output:
24Example 3
Input:
[[2,3,9,10,7,8,6,5,4,11,1]]Expected Output:
1025