Desquared interview question

Balanced sums problem for the algorithmic part