I don't understand this question.

  • 0

    How is it that
    [2,1,0,0] is true
    [2,5,0,0] is false?

  • 0

    [2,1,0,0] is false and [2,5,0,0] is true.
    You can test it using any passed code from Discuss.

  • 0

    I rather not look at the solutions when it's the wording I don't understand.

    I figured it out using different test cases, especially [2,1,0,0] and [1,2,0,0], where the former is False and the latter is True.

    Through this I saw that order matters in the iteration, so the answer is not based on a running total. You keep track of the current reachable index, which is the current index + nums[currentIndex] or a previous reachable index if it is greater, and see if the current index is reachable. If it's not then you know you can't make it to the end.

    Pretty easy greedy problem, but the wording got me.

Log in to reply

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