题解 | #跳跃游戏(一)#

跳跃游戏(一)

http://www.nowcoder.com/practice/23407eccb76447038d7c0f568370c1bd

import java.util.*;

public class Solution { public static boolean canJump(int[] nums) { int res=0; for (int i = 0; i < nums.length; i++) { if(i>res) return false; res=Math.max(res,i+nums[i]); if(res>=nums.length-1) return true; } return false; } }

全部评论

相关推荐

点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务