Class Solution

java.lang.Object
g0001_0100.s0055_jump_game.Solution

public class Solution extends Object
55 - Jump Game.<p>Medium</p> <p>You are given an integer array <code>nums</code>. You are initially positioned at the array&rsquo;s <strong>first index</strong> , and each element in the array represents your maximum jump length at that position.</p> <p>Return <code>true</code> <em>if you can reach the last index, or</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [2,3,1,1,4]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Jump 1 step from index 0 to 1, then 3 steps to the last index.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [3,2,1,0,4]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> 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.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 10<sup>4</sup></code></li> <li><code>0 <= nums[i] <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • canJump

      public boolean canJump(int[] nums)