Man, your solutions are way more simpler to understand than any other solutions available on internet. Most of them copy from geeks for geeks and we need Big brain to understand those.
Very good solution. Just one thing to add, you missed to check if stepsPossible becomes < 0 after line number 29. i.e. your solution will give wrong answer for this test case below : 5 0 1 1 1 1 So, just add one more check: if(stepsPossible < 0) return -1; It will work fine. Thanks again for this concept. Loved it.
Very helpful video. Not many show such visualization and bcos of this visualization, I understood y maxReach - i. Also, not many use Vim. Glad to see another vim user. I'm sure by now, you might have learnt better way to navigate Vim. And this video was so easy to understand and helpful. Thanks :)
I couldn't get why jump begins from 1? arr[0] is 1 so going to arr[1] seems a step not jump. Jump is something when currently we don't have step. If we consider an array like {5,2,4,1} we need not any jump here, isn't ?
Thank you for this demo. But please may I ask you one question : I have tried to solve this array but it does not giving me the good solution : int arr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; jumps must to be 10, but it gives 11
better than the paid contents. I just have one query, I was able to come up with recursive and bottom up dp on my on. how do I come up with O(n) solutions. seeing it makes it obvios, but how do we take a dp sol say, and then reduce complexity further. Anyways, great conent, subscribed and liked. Pls reply , getting started with recusrsion and dp.
One thing I'm still not getting is that why we need 3 jumps when we can directly jump from ele 3 to ele 9 and only 2 jumps are required. Geeks for Geeks showed sol. Like (1->3->8->9 ) 3 jumps didn't get this part Please help buddy
Man, your solutions are way more simpler to understand than any other solutions available on internet.
Most of them copy from geeks for geeks and we need Big brain to understand those.
Thank you so much bro ☺️☺️
It's copied from GEEKSFORGEEKS only lol
Very good solution. Just one thing to add, you missed to check if stepsPossible becomes < 0 after line number 29. i.e. your solution will give wrong answer for this test case below :
5
0 1 1 1 1
So, just add one more check: if(stepsPossible < 0) return -1;
It will work fine. Thanks again for this concept. Loved it.
Explaining this algorithm is not a cup of tea for everyone
But you nailed it man
credits to you.!!
Very helpful video. Not many show such visualization and bcos of this visualization, I understood y maxReach - i. Also, not many use Vim. Glad to see another vim user. I'm sure by now, you might have learnt better way to navigate Vim.
And this video was so easy to understand and helpful. Thanks :)
Sir, if maxReachable exceeds n-1, why don't we return then and there. This way we may not need to run for loop till i
I liked your idea, very helpful to see you solved a problem from brute-force to most optimal solution.
Hey bro, videos are really beginner-friendly. Gave a nice idea on how to approach such problems. Keep posting such quality contents
Thanks so much yaar 😁✨🙏🙏
I couldn't get why jump begins from 1? arr[0] is 1 so going to arr[1] seems a step not jump. Jump is something when currently we don't have step. If we consider an array like {5,2,4,1} we need not any jump here, isn't ?
Good explanation vro!
You can optimise a bit by
if(maxReach>=(n-1))
return jumps+=1;
So we need not to go till i==n-1
What if
Using maxreachable we are not reaching the n-1
And some other value lower then maxreachable is taking us to the n-1
this background noise is so irritating, it distracts very much :(
I see you use Vim too , finally a man of culture.
I smell Madox here.....😂😂 But yeah he is man of culture
Reallly Good Solution! Saw the same kind of solution on GFG but couldnt understand why steps= maxReachable -i ; This cleared it Up. Thanks g
Thank you for this demo. But please may I ask you one question : I have tried to solve this array but it does not giving me the good solution : int arr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; jumps must to be 10, but it gives 11
because he is considering reaching the first element as 1 .. in your ques..it might be that we start from pos 1(index 0)
Great explanation
this was very helpful, very good exaplanation.
Why can't we re-initialise, steps = arr[i] instead of steps = maxReachable - i (according to your code)
neat and crisp explanation keep it up!!!
better than the paid contents.
I just have one query, I was able to come up with recursive and bottom up dp on my on.
how do I come up with O(n) solutions. seeing it makes it obvios, but how do we take a dp sol say, and then reduce complexity further.
Anyways, great conent, subscribed and liked.
Pls reply , getting started with recusrsion and dp.
great expalanation bro
One thing I'm still not getting is that why we need 3 jumps when we can directly jump from ele 3 to ele 9 and only 2 jumps are required.
Geeks for Geeks showed sol. Like
(1->3->8->9 )
3 jumps didn't get this part
Please help buddy
I dint quit get why r we decreamenting steps.Can anyone help???????
first condition is missed if arr[0] == -1 edge case
Nice Explanation
adding "if (arr[0] == 0) return -1;" at the beginning of the function will pass the testcase 0 1 1 1 1
it's not Dp its greedy Dp is working in O(n^2)
isaka koi intuition bata skata h ya
awesome video bro .... Thank you ...... subscribed now ..... hope you make more good explanation videos like this.
this one is not the dynamic programming approach but the greedy approach. Kindly correct on title
or correct me if I'm wrong and this is the dynamic approach itself XD
@@whynesspower you are right. this is greedy and not DP
arre bhai background music toh band kar lo
very helpful mam
Mam 😂😂😂lol