Minimum number of jumps | Array | Love Babbar DSA Sheet
VloĆŸit
- Äas pĆidĂĄn 1. 08. 2021
- C++ Code Link : github.com/Ayu-99/Love-Babbar...
Python Code Link: github.com/Ayu-99/Love-Babbar...
Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
#DataStructuresAndAlgorithms
#LoveBabbarDSASheet
#interviewpreparation
Minimum number of jumps solution
Minimum number of jumps Leetcode
Minimum number of jumps C++
Minimum number of jumps C++ Hindi
Minimum number of jumps Hindi
Checkout the series: đ„đ„đ„
đ Recursion : âą Recursion
đ Stack and Queue : âą Stack And Queue
đ Greedy : âą Greedy
đ Leetcode contests : âą Leetcode contests
đ Leetcode June Challenge : âą Leetcode June Challenge
đ Leetcode July Challenge : âą Leetcode July Challenge
LIKE | SHARE | SUBSCRIBE đ„đ„đ
Really, you are explaining everything very clearly...Hope to see you with some more DSA videos!đđ
Hey Ayushi, thanks for the awesome series !! Please continue đ
Sure thanks đ
Effort is real! Thank you so much!
Thank you Hiten đ
Thank u for explaining it. Finally understood.
Thank you so much Ayushi. I had watched 4 videos before this one and was still confused. But your video finally made the solution clear to me!! God bless you đ
Thank you so much Shubham đ€đ€
confused a lot , but you cleared all my confusion , thank you mam!!!
Welcome, glad it was helpful đ
pura youtube search kiye koi itna accha nhi smjhaya .....
thanks a lot aap mera depresssion kam kr diye
yeh qs solve kr liye
Very Very simple and easy explanation. Thankyou Ma'am
Welcome. Glad it helped :)
Vah yaar samaj gaya akhir!!thanks sub. Kr diya hai abhi apbhi mere dsa teacher me add ho gaye!đ
Very well explained!!!
Great explanation, Thank you mam.
Good approach. Basically you are trying to simulate BFS like traversal.
Can you please explain what do you mean by steps here? And when you say " Aaage badh rhe hai toh steps ghata denge". I don't understand why we are decreasing the value of "steps" variable (
same doubt.....
Here the question states that if the element is 'n' here can take a leap of maximum n number means if the a[i] =5 we can take step 0 or 1 or 2 or 3 or 4 or 5.... So if we want to iterate till the step,,, we are first storing ar[5] in step variable then we are decreasing to iterate till the next 5 position
Steps means possible choices to land so that after jump you get maximum reach
Great effort keep it up!
Thank you :)
best explanation...Thanks for amazing explanation
Welcome! glad it was helpful :)
I have never seen this kind of explanation. thanks
Thanks a lot đ€
Tysm .I admire how u explained everything with patience.
Thank you Dineshđ Glad it was helpful!
Great explanation ma'am !
Thank you :)
Add this in DP playlist as well :)
Thank you soo much , finally understood the problem solution
Welcome Madhurimađ
Thankyou mam, Much better explanation than Apni kaksha! I mean it
Welcome Tanish, glad it was helpful :)
Gfg
Great explanation Hope to see more problems....
Thank you :). Yes, I will try my best to cover the sheet asap
thanks Ayushi was nt able to understand this today while trying
Welcome. Glad it helped :)
itna confuse kyu ho rhi h bhen tu sahi smjha rhi h đ or sbko smjh bhi aara h kudos đ
55 jump game Leetcode
Thank you so much for this wonderful videoâ€ïžđ§ż
Welcome Anshuman, glad it was helpful đ€đ€
thanks for the video.
thanks yaar ayushi. It was indeed helpful
Welcome Shivani :)
in that some confusion i not understand properly in that my fault
but you explained very well. thank you
perfect vidio finally
really awesome explained thanks
Thank you, I'm glad it was helpful :)
why can we write if(maxreach>n) return jump;
Very nice explanation thanks
Welcome Rajendra, glad it was helpful :)
Plz Provide intution for this approach
very nicely explained :)
Thank you :)
great explanation :D
thank you :)
great explaination
thanks, glad it was helpful :)
u explained it the besttt.
thank you, glad it was helpful :)
Great Aayushi
Thank you so much sirđ
Good upload
thanks finally samajh me aa gya .
đ€đ€ welcome
@@AyushiSharmaDSA mam please iske recursive solution explain krdo.
Great teaching skills,Nice Explanation đ
Thank you :) . Please share channel with your friends and juniors đ
Nice Explanation
Thank you Urvish, glad it was helpful :)
Not explained clearly. You are just dry running the code and not telling the intuition and reason behind it.
When our maxReach becomes >= arr.length, can't we return jump from there rather than traversing whole loop?
Your videos and explanations are awesome mam please upload videos in English mam
THANX
Thank you
Welcome đ€
thank you ma'am đđ
Most welcome đ
Queenđ
đđ
At index 3 maxReach=11 which is >=n-1, which means that we can reach at least at index 11(even if it does'nt exist) also we are taking maximum steps at each index, so we can also reach index 10 i.e last index so even after that why do we still continue?
You can try adding a break after that and check if all test cases pass
@@AyushiSharmaDSA No they don't. We get our answer after reaching at n-1 only.
What could be the reason?. I tried multiple cases but couldn't find the reason.
Your approach is correct, but implementation might be wrong, instead of break, just return jumps+1; also add a cehck initially that if arr[0]>=n-1 return jumps
Here is my implementation:
public class MinimumNumberOfJumps {
private static int getMinimumNumberOFJumps(int arr[]){
int n=arr.length;
if(n=n-1)
return jumps;
for(int i=1;i=n-1){ // We already have the last index inside the current radar from this ith element.
return jumps+1;
}
steps--;
if(steps==0){
// Before moving to the next jump, we check if we have reached zero valued elements and have reached index>=max_range
if(i>=max_range)
return -1;
jumps++;
steps=max_range-i;
}
}
return jumps;
}
why I don't know but I found it very difficult to understand?
me also
The way you explained is quite impressive... just reiterating like others, I too had watched other videos but got clarity by watching this.. Subscribing to your channel right away.. Keep doing good work...keep inspiring...kudos!!
So nice of you , thanks Anant đ€đ„čđ€©
Sis from where can we practise questions coding which are asked in accenture, tcs , tech mahindra, wipro .
check from gfg, prepinsta or faceprep
It would be better if you could share the link to problem as well in the description!
Okay. Thanks for suggestion. I will do from next video.
Great teaching method..
Do you have any example for which we cannot reach to the end and we have to return -1? for the edge case of i>=maxreach?
2 1 0 3
Can you get this.. please explain
@@rupalisharma2674 arr[0] :- step = 2, so we can move 1 step or 2 step. with the 2 step we reaches 0 , and with step 1 we reaches 1 and after one there is only one 1 step . with 1 one step we reaches 0 .
with both cases the solution is not possible thats why i>=maxrech, beacuse at zero maxreach =0, and i=2.
@@harshthakur9890 ohhk.get it... thankyou so much đđ»đ
Op yrrđ§Ąđ
Thanks Abhishek :)
Thank u so much , im just one year late in watching this video đ đ ....
Itâs never too late brooo, glad u liked it đ€đ€đ€©
Can you please tell the time complexity of this approach? Thanks for the video btw!
Time Complexity =O(n)
Very Good Didi...
just one thing...mention if it is greedy or dynamic in thumbnail pls
Thank you Akash, sure :)
thanks
Welcome :)
one edge case is missing in python code
if len(arr) = 1
return 0
What u use for writing? Mouse or some type of other device
Hi, I use mouse
Nice
Thanks :)
Thanks mam
And those who are not understanding why i>=max
for them just use this
if(step==0){
step=maxReach-i;
if(step
Thanks Jaskaran đđđ»
thx
Welcome, glad it was helpful :)
How can a begginer will get this logic ?
i didnt get this step
if( i>=max_reach )
return -1
no ones intuition clear in this question, just every one copied solution from gfg and making dry run here. please dont do this.
you are only explaning the the code not the intution ,though efforts are lot !!
The time complexity of the brute force approach is n! not exponential
can you please explain line no 31 in more detail?
edge case should be
if(n==1){
return 0;
}
why can't we replace (maxReach - i) with just arr[i] ???????????????????????????
Mam jo questions interview mein ask karte hai interview mein woo maximum questions leetcode ke hote hai yaa other platforms ke
It's not specific.
@@AyushiSharmaDSA okay mam
Why do we write if(i>maxreach) condition pls explain
condition when the maxreach cannot reach the end or of a zero is present in between.
It's Not DP based solution right? Because in DP based Solution The Minimum steps to reach to current element should be calculated from Minimum jumps of Previous elements.
You can do with dp too as follows :
class Solution{
public:
int minJumps(int arr[], int n){
// Your code here
vector dp(n, 1e7+1);
int ans = solve(arr, dp, 0 , n);
if(ans == 1e7+1)return -1;
return ans;
}
int solve(int * nums, vector& dp, int pos , int n) {
if(pos >= n - 1) return 0;
if(dp[pos] != 1e7+1) return dp[pos];
for(int j = 1; j
kitna confusing ha yrr aap khud itna confuse ha baccho ki samjhao gi dii dii
Correct
@@ShivaniGupta-xj1sp which year
Bro your mind is so much disturbed and only thinking about lost things .so you are not able to understand this problem
@@manasjena5124 I a study platform so I am not saying anything but oversmart bna sa Tera Ghar nhi chalega
crisppp
Why if (i>=maxReach) explain in English mam
wont work for the array 2,1,1
class Solution
{
public:
int minJumps(int arr[], int n)
{
int jump = 0,i=0,k=arr[0];
do
{
jump++;
i=i+k;
k=arr[i];
}while(i
Because in this code you always jump maxi no. If you on a place where 3 is present you jump only 3step not 2 or 1step if on 1step 9 is present and on 3step 1is present. you need first 1step then 9step not 3step then 1step
step = maxReach - i;
if (step == 0) // for 2 1 0 3 test case
return -1;
&&
if (i == maxReach) // for 2 1 0 3 test case
return -1;
step = maxReach - i;
are same .
ab hum aagge steps he nahi le sakte toh return -1.
how to code this
@@girdhar3224 if (n
Striver bhaiya ki sheet ke question bhi solved kijiye plz
Hi Mayank, actually striver is solving that sheet, but kafi common ques hai, I will cover them. Thank you for suggesting. :)
@@AyushiSharmaDSA ohk thanksđđŻ
Better than the Code explainer. I was fed up of this stupid voice. Good work
Thank you :) glad it was helpful
@@AyushiSharmaDSA yes it was and soon i am going to interview you on my youtube channel. If you are ready, please accept my LinkedIn connection request mam.
The fumbles in between the explanation creates a lot of confusion.đŁ
Mam hindhi may padho na recurion đ
badhya bateye laiken manna padga
not good
10:04 9+8 is 18 (mistake)
đ đ
chatgpt se chaap diya
9+8=18 at 10:03 đ
đđđ
Can u please explain in English
Hi, Sure, this was old video, new videos are in English :)
Referal milegaa kya
Zaroor milega, job id Aur resume bhejo linkedin pe
plz dont show the solution at the starting of the video .because i am to trying come up with the solution if you show the solution directly at the first i am getting the hints. plz cover the code and at last show mw the code(you are killing my thinking of the approuch.
Hey, sure think, usually in my videos, I show code at end only. :)
could you explain i >= maxreach condition if possible
If current index becomes greater than maxreach, then it means that we got minimum jumps
@@AyushiSharmaDSA so why are we returning -1 then
@@hemesh5663 sorry, in the problem, we have to go till end, so if i had become greater than max Reach, so this is not ideal case as i should be less than max reach
Dry run once with a test case
@@AyushiSharmaDSA so basically that condition will work if we encounter a zero right in our path that what I understood correct me if I am wrong pls