题目:
题解:
Go
func jump(nums []int) int {
length := len(nums)
end := 0
maxPosition := 0
steps := 0
for i := 0; i < length - 1; i++ {
maxPosition = max(maxPosition, i + nums[i])
if i == end {
end = maxPosition
steps++
}
}
return steps
}
func max(x, y int) int {
if x > y {
return x
}
return y
}