题目:
题解:
// 贪心算法
func canJump(nums []int) bool {cover := 0n := len(nums)-1for i := 0; i <= cover; i++ { // 每次与覆盖值比较cover = max(i+nums[i], cover) //每走一步都将 cover 更新为最大值if cover >= n {return true}}return false
}
func max(a, b int ) int {if a > b {return a}return b
}