```
func jump(nums []int) int {
if nums == nil || len(nums) <= 1 {
return 0
}
i, count, n := 0, 0, len(nums) - 1
j, k, max, j0 := 0, 0, 0, 0
for i < n {
if i + nums[i] >= n {
return count+1
}
max, k = 0, i + nums[i]
for j = i + 1; j <= n && j <= k; j++ {
if j + nums[j] > max {
max, j0 = j + nums[j], j
}
}
i = j0
count++
}
return count
}
```