Last active
April 25, 2020 19:15
-
-
Save munguial/0740018be25274f3c268016df29ec14f to your computer and use it in GitHub Desktop.
Day 25 - Jump Game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/531/week-4/3310/ | |
class Solution { | |
fun canJump(nums: IntArray): Boolean { | |
var aux = BooleanArray(nums.size) | |
aux[aux.size - 1] = true | |
for (i in nums.size - 1 downTo 0) { | |
if (aux[i]) { | |
for (j in i - 1 downTo 0) { | |
if (nums[j] >= i - j) { | |
aux[j] = true | |
} | |
} | |
} | |
} | |
return aux[0] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment