LeetCode Day 25 - Jump Game (DP or Greedy?)

preview_player
Показать описание
Elements of the array tell us how far to the right we can jump. Can we get to the end?

Subscribe for more educational videos on algorithms, coding interviews and competitive programming.

#Coding #Programming
Рекомендации по теме
Комментарии
Автор

Educative giveaway winners were contacted via email on May 2.

Errichto
Автор

I appreciate that your explanation are so intuitive. Almost making logical reasoning seem instinctive

ahmed.rosanally
Автор

At first i did it with segment tree to mark at which stone i can arrive, then I understood that the total interval must be continous. It made it much easier.
int m = 0; //the last stone you can get to
for(int i = 0;i < nums.size();i++){
if(m < i) return 0;
m = max(m, i + nums[i]);
}
return 1;

rentib
Автор

Solving the minimum jumps you inadvertently solved jump game 2 problem on leetcode

ishaangupta
Автор

hey you got some money dude ! congrats !

camper
Автор

Some people look down on these problem, meaning it’s too easy. But there are many ways to achieve the goals, and implementing quickly is a challenge. Love your videos which are very inspiring

yunjiehong
Автор

bool canJump(vector<int>& a) {
int n = a.size();
int target = n - 1;
for (int i = n - 2; i >= 0; i--) {
if (i + a[i] >= target) target = i;
}
return target == 0;
}

xmingw
Автор

`LeetCode` is just a great place to learn a lot. And solving programming challenges within time frame is just awesome. This inspired me create my own channel which solves coding problems of sololearn community challenges every weekend. And uploading my next challenge in a while.

front-end-forge
Автор

Thanks Errichto -- these videos so good!

jimwoodward
Автор

can anyone tell where can I get that timer? looks like it is the same timer that shows up when I google 'timer'... but wanted it to be floating on my screen like Errichto!

lolista
Автор

How many hours u were spending on coding sites .when u started solving problem on earlier days?

RN-jozt
Автор

I appreciate you try so hard to think like a normal programmer instead of a pro, I really appreciate it, but can you turn back to pro mode once in a while?? thank you

whitesalmon
Автор

Amazing video! Any advice for anyone trying to self teach math? Spec with a programming focus.

rafaeldietrich
Автор

For Java Programmers, instead of using pair class, we can use two integer variable num1 and num2
and initialize these values with 0, 0 and then later in while loop we can update their values as we do for pair class. Easy

shrad
Автор

Can you be a bit slower at time and space complexity analysis please? Love this series of yours by the way! Really glad I found your channel <3

ZzwhiskeybkszZ
Автор

7:31 in second solution you always do n steps, even if first jump can reach end position.

AlexSav
Автор

@Errichto can you please give us a DP solution?

poo
Автор

BFS (with queue) solution works well for this problem.

osmanay
Автор

"Make it slightly bigger" has to be in every video

hellowill
Автор

Increase the font just a little more @Errichto

syeda.k.