Skip to content

Instantly share code, notes, and snippets.

@munguial
Last active April 25, 2020 19:15
Show Gist options
  • Save munguial/0740018be25274f3c268016df29ec14f to your computer and use it in GitHub Desktop.
Save munguial/0740018be25274f3c268016df29ec14f to your computer and use it in GitHub Desktop.
Day 25 - Jump Game
// 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