Python
Using the integers from the problem statement:
seqs = [
[0, 1, 2, 3],
[4, 7, 8, 9],
[10, 12, 14, 15, 17],
]
We write the following function:
def hais(seqs):
results = [0] * len(seqs)
for ix, seq in enumerate(seqs):
result = seq[0]
add = True
for i in seq[1:]:
if add:
result += i
else:
result -= i
add = not add
results[ix] = result
return results.index(max(results))
Then, we can get the index for our example data:
>>> hais(seqs)
1