odd
and even
to keep track of whether an index can reach the end with an odd or even jump respectively.odd
and even
arrays to True
since the last index can always reach the end.odd[i]
to even[next_greater_index]
.
b. For even jumps, if there is a next smaller index, set even[i]
to odd[next_smaller_index]
.True
values in the odd
array, which represents the number of good starting indices.