For example:
[2, 5, 3, 10] [6, 3, 4, 4, 1], [20, 20] equal on both sides after segmentation,
[2, 5, 3, 11] [6, 3, 4, 4, 2] [22, 20] are not equal on both sides after segmentation,
Use an array of slice (start, end) and reduce ((prev, current, the index)=& gt; {return prev + current; }) method, but for how to implement and high performance without thinking, want to consult everybody here, thank you very much!
CodePudding user response:
The first array sumAgain since the first element in circulation with total minus the current element, if reduced to a certain location, just for half of the total, the result of the reduction is divisible; If the result is less than half of the total, then stop circulation, inseparable,