Loading
Leetcode / 55. Jump Game

Pick a programming language:

Here is the source code for the solution to this problem.

class Solution {
  public boolean canJump(int[] nums) {
      int jumps = 0;

      for (int i = 0; i < nums.length; i++)
      {
          if (jumps < 0)
          {
              return false;
          }
          else if (nums[i] > jumps)
          {
              jumps = nums[i];
          }
          jumps--;
      }

      return true;
  }
}
Did you like the lesson? 😆👍
Consider a donation to support our work: