Maximum Product of Splitted Binary Tree

Given a binary tree root. Split the binary tree into two subtrees by removing 1 edge such that the product of the sums of the subtrees are maximized.

Since the answer may be too large, return it modulo 10^9 + 7.

Example 1:

Example 2:

Example 3:

Example 4:

Constraints:

  • Each tree has at most 50000 nodes and at least 2 nodes.

  • Each node's value is between [1, 10000].

Last updated