From 0bb4fde04a1df9adf19da4c4bafbd116d6990dbe Mon Sep 17 00:00:00 2001 From: aartiiyer90 <103495458+aartiiyer90@users.noreply.github.com> Date: Sun, 26 Jun 2022 17:51:44 +0530 Subject: [PATCH] Create 55-Jump-Game.js --- javascript/55-Jump-Game.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 javascript/55-Jump-Game.js diff --git a/javascript/55-Jump-Game.js b/javascript/55-Jump-Game.js new file mode 100644 index 000000000..b11205176 --- /dev/null +++ b/javascript/55-Jump-Game.js @@ -0,0 +1,19 @@ +/** + * @param {number[]} nums + * @return {boolean} + */ +var canJump = function(nums) { + + let goal = nums.length - 1; + + for(let i=nums.length-2;i>=0;i--){ + if(i+nums[i] >= goal){ + goal = i; + } + } + if(goal === 0) + return true; + else + return false; + +};