Jump Game | (C++, Java, Python) |30 day Challenge | Day 25 | LeetCode #55

preview_player
Показать описание

**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

LeetCode 30 day Challenge | Problem 25 | Jump Game | 25 April,
Facebook Coding Interview question,
google coding interview question,
leetcode,
jump game solution,
jump game python,
jump game java,
jump game c++,

#Facebook #CodingInterview #LeetCode #30DayChallenge #Google #JumpGame #Amazon
Рекомендации по теме
Комментарии
Автор

Don't forget to share your solutions which worked for you. Thanks.

KnowledgeCenter
Автор

Nice job. It is somehow related to the problem on dynamic programming about the minimum jumps required to reach the end of the array.

williamwambua
Автор

class Solution {
public boolean canJump(int[] nums) {
int dp[]=new int[nums.length];
Arrays.fill(dp, -1);
return helper(nums, 0, dp);
}
boolean helper(int[] nums, int position, int dp[]){
if(position>=nums.length-1)
return true;
if(dp[position]!=-1)
return dp[position]==1?true:false;
int jumpLength = Math.min(nums[position]+position, nums.length);
for(int i=position;i<jumpLength;i++){
if(helper(nums, i+1, dp)){
dp[position]=1;
return true;
}
}
dp[position]=0;
return false;
}
}

umapathybabu
Автор

this is a classic dp question, but solved in greedy fashion.

srinish
Автор

sir please also give solutions of the atcoder beginner contest please

ayushupadhyaya
Автор

It says this question could be solved by Greedy Algo as well. Which greedy algo you used?

indranilthakur
Автор

Youtube need an "Indian Accent" tag so people can sort out these unbearable videos.

svendbentjensen