博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode——Jump Game
阅读量:7025 次
发布时间:2019-06-28

本文共 587 字,大约阅读时间需要 1 分钟。

Given an array of non-negative integers, you are initially positioned at the first index of the array.

Each element in the array represents your maximum jump length at that position.

Determine if you are able to reach the last index.

For example:

A = [2,3,1,1,4], return true.

A = [3,2,1,0,4], return false.

原题链接:https://oj.leetcode.com/problems/jump-game/

当前的数字代表能跳的长度,看一个数组能不能从開始跳到最后。

public class JumpGame {	public boolean canJump(int[] A) {		int gap=1;		for(int i=0;i
gap) gap = A[i]; if(gap == 0) return false; } return true; }}

版权声明:本文博主原创文章,博客,未经同意不得转载。

你可能感兴趣的文章
2016第5周三
查看>>
Spring学习10-SpringMV核心组件2及SpringMVC项目示例
查看>>
hdu 5620 KK's Steel(推理)
查看>>
(笔记)电路设计(十五)之基本电路单元的认识
查看>>
nginx 日志获取不到远程访问ip问题解决
查看>>
有若干个字符串,比較找出当中最大者
查看>>
开源 免费 java CMS - FreeCMS2.0 会员我的评论
查看>>
Servlet 工程 web.xml 中的 servlet 和 servlet-mapping 标签 《转载》
查看>>
数据库读写分离的初步理解
查看>>
[转]window下使用SetUnhandledExceptionFilter捕获让程序的崩溃
查看>>
Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll 水题
查看>>
代码的组织机制
查看>>
html基础之 input:type
查看>>
json-lib简单处理json和对json的简单介绍
查看>>
jquery checkbox选中、改变状态、change和click事件
查看>>
java joor 实现反射简单调用
查看>>
Guava 8-区间
查看>>
自定义Spark Partitioner提升es-hadoop Bulk效率
查看>>
总结一些机器视觉库
查看>>
在CentOS Linux下部署Activemq 5
查看>>