We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent faf597f commit 1061026Copy full SHA for 1061026
jump-game/minji-go.java
@@ -0,0 +1,19 @@
1
+/**
2
+ * <a href="https://leetcode.com/problems/jump-game/">week10-4. jump-game</a>
3
+ * <li>Description: Return true if you can reach the last index, or false otherwise</li>
4
+ * <li>Topics: Array, Dynamic Programming, Greedy </li>
5
+ * <li>Time Complexity: O(N), Runtime 2ms </li>
6
+ * <li>Space Complexity: O(1), Memory 45.66MB </li>
7
+ */
8
+class Solution {
9
+ public boolean canJump(int[] nums) {
10
+ int jump = 0;
11
+ for (int i = 0; i <= jump; i++) {
12
+ jump = Math.max(jump, i + nums[i]);
13
+ if (jump >= nums.length - 1) {
14
+ return true;
15
+ }
16
17
+ return false;
18
19
+}
0 commit comments