jump
This commit is contained in:
9
jump/index.js
Normal file
9
jump/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// https://www.codewars.com/kata/594fae1a0462da7beb000046
|
||||
|
||||
const canJump = (arr, pos = 0) => {
|
||||
if (pos >= arr.length) return true;
|
||||
for (let i = arr[pos]; i > 0; --i) {
|
||||
if (canJump(arr, pos + i)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user