834. Maximum Product of Splitted Binary Tree (Mod 10^9+7)

HardRecursionRecursion

Remove one edge from binary tree; return max product of two subtree sums, mod p. Level-order input (-1=null).

Input: JSON level-order array (-1=null).

Output: Integer mod p.

Examples

Example 1
Input: [1,2,3,4,5,6]
Output: 90
Explanation: Sums 10 and 9 -> product 90.
Example 2
Input: [1,1]
Output: 1
Explanation: 1*1=1.

Constraints

Asked by

MicrosoftAmazonGoogleMetaBloomberg
Solve this problem in the editor →