MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / Solution

Class Solution

55-jump-game/jump-game.java:3–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1// Jump Game - LeetCode #55
2
3class Solution {
4 public boolean canJump(int[] nums) {
5 int maxReach = 0;
6
7 for (int i = 0; i < nums.length; i++) {
8 if (i > maxReach) return false;
9 maxReach = Math.max(maxReach, i + nums[i]);
10 if (maxReach >= nums.length - 1) return true;
11 }
12
13 return true;
14 }
15}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected