- Prepare
- Data Structures
- Trees
- Balanced Forest
- Discussions
Balanced Forest
Balanced Forest
+ 0 comments The statement of this problem has some defects !!, the output can be >= 0, and the statement says that it is only > 0, in addition to that it is understood that it is to divide the tree into 3, and then add the node, however in fact, you can split it in 2, and create a new tree....
+ 1 comment In my opinion, it is not very sportsmanly to have skeleton code, which will never work - the return second query for sample input 3 should be 759000000000, which is too big to fit in the
int32
return type in the signaturefunc balancedForest(c []int32, edges [][]int32) int32 {
+ 1 comment Consider the last query of Test Input 1:
- 6
- 100 100 99 99 98 98
- 1 3
- 3 5
- 1 2
- 2 4
- 4 6
- Expected 297
How do you get this value? I tried to cut directed edges (1, 3) and (2, 4) to get the balanced trees: 197, 200, 197 but this option fails.
Can we cut the same edge twice? If so I would cut (1, 2) twice to get the balanced trees: 297, 297, 0 and I can insert "297".
+ 1 comment 1 8 1 1 1 18 10 11 5 6 1 2 1 4 2 3 1 8 8 7 7 6 5 7
is this a valid tree?
+ 1 comment Test case 3 has an answer of "759000000000" which requires a long in the driver program not an int.
Sort 71 Discussions, By:
Please Login in order to post a comment