Need clarification


  • 0
    A

    The requirement is just to reach the end somehow or reach the end starting from index 0? If we don't want to start from 1st index then logically we can reach the end by starting from the end?

    I got confused because if I test on
    [1,0,2,1] false
    [1,0,1] false
    [2,2,0,1] true
    I can't understand why the 3rd test should say true?


  • 0
    J

    because when jumping you dont HAVE to go to index + 2, so you can just jump to the next index and then jump to the end from the second index


  • 0
    R

    I agree that the question is a bit unclear, but if you think about it there's only one possible way that it makes sense.
    The numbers in the array are the "maximum" distance you can jump. So for example if the value is 2, you don't have to jump 2 elements, you can jump 1 element, or 2 elements.


Log in to reply
 

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