Given an array of integers eg [1, 2, -3, 1] find whether there is a sub-sequence that sums to 0 and return it (eg [1, 2, -3] or [2,
[1, 2, -3, 1]
0
[1, 2, -3]
[2,
A scala implementation:
List(1,2,3,4).scan(0){_+_}
the result will be List(0, 1, 3, 6, 10) .
or you can:
List(1,2,3,4).scan(0){_+_}.tail
get List(1, 3, 6, 10)