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

跳跃游戏(一)

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; } }

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务