I encounter a problem to let you drop two elements in an array to make the three part\'s sum equal.
Ex:
1 2 4 3 5 2 1
After I drop the 4 and 5, it becomes
The results below are more a "brute" approach, should work for negative numbers as well. Also a version where we can remove any 2 items and split by any index is added. although it's just a pseudo code.
if the array is split by those items we take out...
var count = a.Length (a is input)
// we need:
for i=0; i 0) sumLeft[i] += sumleft[i-1]
sumRight[cnt-1-i] = a[i]; if (i > 0) sumRight[cnt-1-i] += sumRight[cnt-1+1-i]
// calc:
for i=1; ii; j--;
if (sumLeft[i-1] == sumRight[j+1-1] == sum - a[i] - a[j] - sumLeft[i-1] - sumRight[j-1]) return true;
otherwise return false aft cycle
if we can take out any 2 items and split in any position:
for i=0; i