Skip to content

Commit eaad3dc

Browse files
add description for 1343
1 parent bcaef7a commit eaad3dc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/main/java/com/fishercoder/solutions/_1343.java

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@
55
import java.util.HashSet;
66
import java.util.Set;
77

8+
/**
9+
* 1343. Maximum Product of Splitted Binary Tree
10+
*
11+
* 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.
12+
* Since the answer may be too large, return it modulo 10^9 + 7.
13+
*
14+
* Example 1:
15+
* Input: root = [1,2,3,4,5,6]
16+
* Output: 110
17+
* Explanation: Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11*10)
18+
*
19+
* Example 2:
20+
* Input: root = [1,null,2,3,4,null,null,5,6]
21+
* Output: 90
22+
* Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)
23+
*
24+
* Example 3:
25+
* Input: root = [2,3,9,10,7,8,6,5,4,11,1]
26+
* Output: 1025
27+
*
28+
* Example 4:
29+
* Input: root = [1,1]
30+
* Output: 1
31+
*
32+
* Constraints:
33+
* Each tree has at most 50000 nodes and at least 2 nodes.
34+
* Each node's value is between [1, 10000].
35+
* */
836
public class _1343 {
937
public static class Solution1 {
1038
public int maxProduct(TreeNode root) {

0 commit comments

Comments
 (0)