Golang solution


  • 0
    L
    func canJump(nums []int) bool {
    	max := 0
    	for i := 0; i <= max; i++ {
    		if i+nums[i] > max {
    			max = i + nums[i]
    		}
    		if max >= len(nums)-1 {
    			return true
    		}
    	}
    	return false
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.