首页 > 其他分享 >[LeetCode][55]jump-game

[LeetCode][55]jump-game

时间:2023-08-18 15:25:47浏览次数:35  
标签:index return nums 55 pos jump game false true

Content

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.

Return true if you can reach the last index, or false otherwise.

 

Example 1:

Input: nums = [2,3,1,1,4]
Output: true
Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.

Example 2:

Input: nums = [3,2,1,0,4]
Output: false
Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.

 

Constraints:

  • 1 <= nums.length <= 104
  • 0 <= nums[i] <= 105
Related Topics
  • 贪心
  • 数组
  • 动态规划

  • 标签:index,return,nums,55,pos,jump,game,false,true
    From: https://www.cnblogs.com/shea24/p/17640600.html
  • 相关文章

    • LeetCode[55]JumpGame
      ContentYouaregivenanintegerarraynums.Youareinitiallypositionedatthearray'sfirstindex,andeachelementinthearrayrepresentsyourmaximumjumplengthatthatposition.Returntrueifyoucanreachthelastindex,orfalseotherwise.......
    • No_55_JumpGame
      ContentYouaregivenanintegerarraynums.Youareinitiallypositionedatthearray'sfirstindex,andeachelementinthearrayrepresentsyourmaximumjumplengthatthatposition.Returntrueifyoucanreachthelastindex,orfalseotherwise.......
    • games101-homework-notes
      Games101作业笔记Created:2023-06-19T12:00+08:00Published:2023-08-17T16:23+08:00Categories:ComputerGraphics目录pa0hw1ProjectionMatrixTriangleRasterizerprocesshw2insidetrianglerasterize_trianglemyhw2bugs使用\(y+0.5\)setindex导致三角形分裂屏幕两......
    • 8-17|2023-08-16 12:33:55,972 [salt.master :1643][ERROR ][20321] Received
      该日志条目显示了来自于Saltminion(在这里标识为`[master]`,这可能是minion的名称或者是由于其他原因导致的日志格式)的错误,表示minion在执行一个函数时发生了异常。日志内容“`Theminionfunctioncausedanexception`”表示在minion端执行的特定Salt函数引发了一个错误或异常。......
    • 牛客多校赛第9场G Game
      黑板上有一些数字,Alice和Bob轮流操作,每次操作可以选择黑板上的两个数(两个数可以相同),然后在黑板上写下这两个数的异或。谁先写出k谁赢。首先重复的数字是没有用的,进而可以推出除整局游戏的第一步之外,都可以选择保持当前的局面不变.比如如果一个玩家面对的是一个必输的局面,他就......
    • games101-lecture-notes
      Games101课程笔记Created:2023-06-07T20:54+08:00Published:2023-08-16T21:05+08:00Categories:ComputerGraphics目录Lecture01:OverviewofComputerGraphicsmotivation:学了有什么用?课程内容课程资源Lecture02:ReviewofLinearAlgebra点乘叉乘叉乘的作用Lecture03......
    • AGC064C Erase and Divide Game
      题面传送门首先考虑你只插入若干个数怎么做:按位从低到高插入一棵Trie,问题就变成:在Trie上每次可以往左儿子走或者往右儿子走,如果当某个人操作的时候为空节点那么这个人就输了。如果我们可以将这棵树建出来那么这个问题就是好解决的,可惜建不出来。仿照从高到低建Trie的方法,将......
    • VTK 实例55:连通区域分析
      1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkSmartPointer.h>7#include<vtkSphereSource.h>8#include<v......
    • 『题解』ABC261Ex Game on Graph
      题目链接震惊!这个题竟然被神犇szs放进了博弈论里!我真的没看出来除了题面还有哪里像博弈论(也许是因为我菜)。转移方式很显然,按照题面说的做就行了。那么正解也就呼之欲出了。但是我知道大家都会正解,就是魔改的堆优化Dijkstra,所以我想说的是一种歪解,以及它是歪解的原因。歪解......
    • HDU 5500
      ReordertheBooksTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):449    AcceptedSubmission(s):294ProblemDescriptionn(n≤19) booksinthisseries.Everybookhasanumberfrom ......