Tap here to switch tabs
Problem
Submissions

Problem: Maximum Product of Splitted Binary Tree

Try to solve the Maximum Product of Splitted Binary Tree problem.

Statement

Given the root of a binary tree, divide the tree into two separate subtrees by removing exactly one edge such that the product of the sums of the values of the two resulting subtrees is maximized.

Return the maximum product of the sums of the two subtrees modulo 109+710^9 + 7.

Note: You need to maximize the product before taking the modulo operation.

Constraints:

  • The number of nodes in the tree is in the range [2,5imes104][2, 5 imes 10^4].

  • 1≤1 \leq Node.val ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Product of Splitted Binary Tree

Try to solve the Maximum Product of Splitted Binary Tree problem.

Statement

Given the root of a binary tree, divide the tree into two separate subtrees by removing exactly one edge such that the product of the sums of the values of the two resulting subtrees is maximized.

Return the maximum product of the sums of the two subtrees modulo 109+710^9 + 7.

Note: You need to maximize the product before taking the modulo operation.

Constraints:

  • The number of nodes in the tree is in the range [2,5imes104][2, 5 imes 10^4].

  • 1≤1 \leq Node.val ≤104\leq 10^4