Jump Game | Leetcode 55 | Live coding session 🔥🔥🔥

preview_player
Показать описание
Here is the solution to "Jump Game" leetcode question. Hope you have a great time going through it.

1) 0:00 Explaining the problem out loud
2) 1:10 Algorithm walkthrough
3) 2:00 Solution approach
4) 6:00 Coding

For discussion/feedback

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

I found Recursion + Memo easier but yeah it takes more time that way.
Thanks for the approach.

class Solution
{
static int[] memo;
public boolean canJump(int[] nums)
{
memo = new int[nums.length];
Arrays.fill(memo, -1);
return find(nums, 0, nums.length)==1 ? true : false;
}

public int find(int[] nums, int i, int n)
{
if(i==n-1)
return 1;

if(memo[i]!=-1)
return memo[i];

int jump = nums[i];
for(int j=1;j<=jump;j++)
{
if(i+j<n)
{
if(find(nums, i+j, n)==1)
return memo[i] = 1;
}
}
return memo[i] = 0;
}
}

Ryan-mrpn
join shbcf.ru