Check comments in the code.

```
def jump2(self, A):
"""
Basically it's a shortest-path problem.
As an unweighted graph, BFS should be able to solve it in O(|E|).
But as it's an array with non-negative numbers, we can't jump backward.
So we can do better here.
Suppose we devided the arrays into segments depending on the elment
in the array. So for each segment, we find the farthest index we can
jump. For example, the first segment is always A[0]. The second will be
from A[1] to A[A[0]]. The third will be from A[A[0]] to the farthest
index we can find in the second segment. We start looking between
the end of the last segment and the begin of the next segment.
"""
ans = lastIdx = nextIdx = 0
while nextIdx < len(A) - 1:
ans += 1
lastIdx, nextIdx = nextIdx, max(i + A[i] for i in xrange(lastIdx, nextIdx + 1))
return ans
```