This is an Algorithm written in Javascript that checks if an array can be split into two array so that the sum of the different arrays are equal.
Given a non-empty array, if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side return the length of the two arrays as an array but if there is no place to split the array, return -1
canBalance([1, 1, 1, 2, 1]) → [3,2] canBalance([2, 1, 1, 2, 1]) → -1 canBalance([10, 10]) → [1,1]