Minimum number of jumps | Array | Love Babbar DSA Sheet

SdĂ­let
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 đŸ”„đŸ”„đŸ˜Š

Komentáƙe • 180

  • @aasthagracy7022
    @aasthagracy7022 Pƙed rokem +3

    Really, you are explaining everything very clearly...Hope to see you with some more DSA videos!🙏🙏

  • @MrDevOps
    @MrDevOps Pƙed rokem +4

    Hey Ayushi, thanks for the awesome series !! Please continue 🙂

  • @hitenbafna5095
    @hitenbafna5095 Pƙed 2 lety

    Effort is real! Thank you so much!

  • @niteshshahi924
    @niteshshahi924 Pƙed rokem

    Thank u for explaining it. Finally understood.

  • @shubhamkumar170
    @shubhamkumar170 Pƙed rokem

    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 🙂

  • @latchireddiekalavya4683
    @latchireddiekalavya4683 Pƙed 2 lety +1

    confused a lot , but you cleared all my confusion , thank you mam!!!

  • @siddharthrai3486
    @siddharthrai3486 Pƙed rokem +1

    pura youtube search kiye koi itna accha nhi smjhaya .....

    • @siddharthrai3486
      @siddharthrai3486 Pƙed rokem

      thanks a lot aap mera depresssion kam kr diye
      yeh qs solve kr liye

  • @shreyvardhandhiman
    @shreyvardhandhiman Pƙed 3 lety +2

    Very Very simple and easy explanation. Thankyou Ma'am

  • @code-a-mania4100
    @code-a-mania4100 Pƙed rokem +1

    Vah yaar samaj gaya akhir!!thanks sub. Kr diya hai abhi apbhi mere dsa teacher me add ho gaye!🙂

  • @edryn9368-cj5zb
    @edryn9368-cj5zb Pƙed 11 měsĂ­ci +1

    Very well explained!!!

  • @sanketmane5838
    @sanketmane5838 Pƙed rokem

    Great explanation, Thank you mam.

  • @babhijit
    @babhijit Pƙed 2 lety

    Good approach. Basically you are trying to simulate BFS like traversal.

  • @meeraraj2163
    @meeraraj2163 Pƙed rokem +14

    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 (

    • @VishalGupta-ki8dd
      @VishalGupta-ki8dd Pƙed rokem

      same doubt.....

    • @hariommishra4547
      @hariommishra4547 Pƙed rokem

      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

    • @satyampatil7969
      @satyampatil7969 Pƙed rokem

      Steps means possible choices to land so that after jump you get maximum reach

  • @sahilsingh716
    @sahilsingh716 Pƙed 2 lety +2

    Great effort keep it up!

  • @gandhijainamgunvantkumar6783

    best explanation...Thanks for amazing explanation

  • @abul_khasim1730
    @abul_khasim1730 Pƙed rokem

    I have never seen this kind of explanation. thanks

  • @Dineshsharma-ec6ys
    @Dineshsharma-ec6ys Pƙed 2 lety +8

    Tysm .I admire how u explained everything with patience.

  • @saurabhnikam
    @saurabhnikam Pƙed 3 lety +1

    Great explanation ma'am !

  • @gouravkumar7949
    @gouravkumar7949 Pƙed 3 lety +3

    Add this in DP playlist as well :)

  • @madhurimachowdhury9536
    @madhurimachowdhury9536 Pƙed 2 lety

    Thank you soo much , finally understood the problem solution

  • @tanishsharma5440
    @tanishsharma5440 Pƙed 2 lety +3

    Thankyou mam, Much better explanation than Apni kaksha! I mean it

  • @ajit287
    @ajit287 Pƙed 3 lety

    Great explanation Hope to see more problems....

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 3 lety

      Thank you :). Yes, I will try my best to cover the sheet asap

  • @NitinKumar-gv4hs
    @NitinKumar-gv4hs Pƙed 3 lety

    thanks Ayushi was nt able to understand this today while trying

  • @iambasera
    @iambasera Pƙed 7 měsĂ­ci

    itna confuse kyu ho rhi h bhen tu sahi smjha rhi h 😂 or sbko smjh bhi aara h kudos 🎉

  • @anshumansharma1069
    @anshumansharma1069 Pƙed rokem +1

    55 jump game Leetcode
    Thank you so much for this wonderful videoâ€ïžđŸ§ż

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed rokem

      Welcome Anshuman, glad it was helpful đŸ€—đŸ€—

  • @aasifali9139
    @aasifali9139 Pƙed rokem

    thanks for the video.

  • @rachaelgreene762
    @rachaelgreene762 Pƙed 2 lety

    thanks yaar ayushi. It was indeed helpful

  • @RAHULKUMAR-rs5he
    @RAHULKUMAR-rs5he Pƙed 10 měsĂ­ci

    in that some confusion i not understand properly in that my fault
    but you explained very well. thank you

  • @MusicbyMangesh
    @MusicbyMangesh Pƙed 5 měsĂ­ci

    perfect vidio finally

  • @ashwani_kumar_rai
    @ashwani_kumar_rai Pƙed 2 lety

    really awesome explained thanks

  • @yourentertainer19
    @yourentertainer19 Pƙed 2 lety +1

    why can we write if(maxreach>n) return jump;

  • @RAJENDRASHARMA-xt8uu
    @RAJENDRASHARMA-xt8uu Pƙed 2 lety +1

    Very nice explanation thanks

  • @sanushgowdabr7217
    @sanushgowdabr7217 Pƙed 2 lety +2

    Plz Provide intution for this approach

  • @kamleshlohani6149
    @kamleshlohani6149 Pƙed 2 lety

    very nicely explained :)

  • @InderjeetSingh-eb8py
    @InderjeetSingh-eb8py Pƙed 2 lety

    great explanation :D

  • @siddhartharawat7354
    @siddhartharawat7354 Pƙed 2 lety

    great explaination

  • @sattwickghosh0697
    @sattwickghosh0697 Pƙed 11 měsĂ­ci

    u explained it the besttt.

  • @sachinbagga5916
    @sachinbagga5916 Pƙed 3 lety

    Great Aayushi

  • @testaccount3310
    @testaccount3310 Pƙed 3 lety

    Good upload

  • @tusharvaish8096
    @tusharvaish8096 Pƙed rokem

    thanks finally samajh me aa gya .

  • @bharatnihar
    @bharatnihar Pƙed 2 lety +4

    Great teaching skills,Nice Explanation 😊

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety +1

      Thank you :) . Please share channel with your friends and juniors 🙏

  • @urvishrupareliya8210
    @urvishrupareliya8210 Pƙed 2 lety

    Nice Explanation

  • @ujjwalgupta8725
    @ujjwalgupta8725 Pƙed 11 měsĂ­ci +2

    Not explained clearly. You are just dry running the code and not telling the intuition and reason behind it.

  • @rahul08it
    @rahul08it Pƙed 5 měsĂ­ci

    When our maxReach becomes >= arr.length, can't we return jump from there rather than traversing whole loop?

  • @m.kaviyarasanshan789
    @m.kaviyarasanshan789 Pƙed rokem

    Your videos and explanations are awesome mam please upload videos in English mam

  • @OmSingh-ro2mj
    @OmSingh-ro2mj Pƙed 11 měsĂ­ci

    THANX

  • @ICHIBAN722
    @ICHIBAN722 Pƙed rokem

    Thank you

  • @aniketkirar1194
    @aniketkirar1194 Pƙed 2 lety

    thank you ma'am 😇😇

  • @abhishekjagtap1069
    @abhishekjagtap1069 Pƙed 2 lety

    Queen🛐

  • @jaykotak2698
    @jaykotak2698 Pƙed 2 lety +4

    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?

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety

      You can try adding a break after that and check if all test cases pass

    • @jaykotak2698
      @jaykotak2698 Pƙed 2 lety +1

      @@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.

    • @sidddddddoo7
      @sidddddddoo7 Pƙed 2 lety

      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

    • @sidddddddoo7
      @sidddddddoo7 Pƙed 2 lety

      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;
      }

  • @shamssalehin2376
    @shamssalehin2376 Pƙed 2 lety +2

    why I don't know but I found it very difficult to understand?

  • @AnantKumar-qf2ep
    @AnantKumar-qf2ep Pƙed rokem

    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!!

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed rokem

      So nice of you , thanks Anant đŸ€—đŸ„čđŸ€©

  • @anveshreddy1245
    @anveshreddy1245 Pƙed 3 lety +2

    Sis from where can we practise questions coding which are asked in accenture, tcs , tech mahindra, wipro .

  • @sandeepns4732
    @sandeepns4732 Pƙed 3 lety +1

    It would be better if you could share the link to problem as well in the description!

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 3 lety +2

      Okay. Thanks for suggestion. I will do from next video.

  • @priyankajhamb7061
    @priyankajhamb7061 Pƙed 2 lety +8

    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?

    • @ss-ny2oh
      @ss-ny2oh Pƙed 2 lety +1

      2 1 0 3

    • @rupalisharma2674
      @rupalisharma2674 Pƙed 2 lety

      Can you get this.. please explain

    • @harshthakur9890
      @harshthakur9890 Pƙed 2 lety +1

      @@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.

    • @rupalisharma2674
      @rupalisharma2674 Pƙed 2 lety

      @@harshthakur9890 ohhk.get it... thankyou so much đŸ‘đŸ»đŸ˜‡

  • @abhishekrawat664
    @abhishekrawat664 Pƙed 2 lety

    Op yrr🧡🙌

  • @alt-f4gaming222
    @alt-f4gaming222 Pƙed rokem

    Thank u so much , im just one year late in watching this video 😅😅 ....

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed rokem

      It’s never too late brooo, glad u liked it đŸ€—đŸ€—đŸ€©

  • @okbye6979
    @okbye6979 Pƙed 2 lety

    Can you please tell the time complexity of this approach? Thanks for the video btw!

  • @akashkumardas1130
    @akashkumardas1130 Pƙed 2 lety

    Very Good Didi...
    just one thing...mention if it is greedy or dynamic in thumbnail pls

  • @AmanSharma-vb5jl
    @AmanSharma-vb5jl Pƙed 2 lety

    thanks

  • @bhagyashrighuge4170
    @bhagyashrighuge4170 Pƙed 2 lety

    one edge case is missing in python code
    if len(arr) = 1
    return 0

  • @saunaknandi1814
    @saunaknandi1814 Pƙed 2 lety

    What u use for writing? Mouse or some type of other device

  • @sohel4633
    @sohel4633 Pƙed 2 lety

    Nice

  • @jaskaransingh5346
    @jaskaransingh5346 Pƙed 2 lety +2

    Thanks mam
    And those who are not understanding why i>=max
    for them just use this
    if(step==0){
    step=maxReach-i;
    if(step

  • @DhananjayKumar-vn5tc
    @DhananjayKumar-vn5tc Pƙed 2 lety

    thx

  • @tusharvaish8096
    @tusharvaish8096 Pƙed rokem +1

    How can a begginer will get this logic ?

  • @aayushreejaiswal1568
    @aayushreejaiswal1568 Pƙed rokem

    i didnt get this step
    if( i>=max_reach )
    return -1

  • @avdharna1978
    @avdharna1978 Pƙed rokem +1

    no ones intuition clear in this question, just every one copied solution from gfg and making dry run here. please dont do this.

  • @Rohitrootn
    @Rohitrootn Pƙed rokem +1

    you are only explaning the the code not the intution ,though efforts are lot !!

  • @fuehrercheem2447
    @fuehrercheem2447 Pƙed 2 lety

    The time complexity of the brute force approach is n! not exponential

  • @shambhavisharma6283
    @shambhavisharma6283 Pƙed rokem

    can you please explain line no 31 in more detail?

  • @mohitkumarsuman8224
    @mohitkumarsuman8224 Pƙed 2 lety

    edge case should be
    if(n==1){
    return 0;
    }

  • @Prathmeshnandurkar
    @Prathmeshnandurkar Pƙed rokem

    why can't we replace (maxReach - i) with just arr[i] ???????????????????????????

  • @dhruvratra992
    @dhruvratra992 Pƙed 3 lety

    Mam jo questions interview mein ask karte hai interview mein woo maximum questions leetcode ke hote hai yaa other platforms ke

  • @vatsalsrivastava4001
    @vatsalsrivastava4001 Pƙed 2 lety

    Why do we write if(i>maxreach) condition pls explain

    • @rishireji4313
      @rishireji4313 Pƙed 6 měsĂ­ci

      condition when the maxreach cannot reach the end or of a zero is present in between.

  • @shreyashmalu2491
    @shreyashmalu2491 Pƙed 2 lety +1

    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.

    • @kapil4457
      @kapil4457 Pƙed rokem

      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

  • @tbmsahil8850
    @tbmsahil8850 Pƙed rokem +18

    kitna confusing ha yrr aap khud itna confuse ha baccho ki samjhao gi dii dii

    • @ShivaniGupta-xj1sp
      @ShivaniGupta-xj1sp Pƙed rokem +1

      Correct

    • @tbmsahil8850
      @tbmsahil8850 Pƙed rokem +1

      @@ShivaniGupta-xj1sp which year

    • @manasjena5124
      @manasjena5124 Pƙed měsĂ­cem

      Bro your mind is so much disturbed and only thinking about lost things .so you are not able to understand this problem

    • @tbmsahil8850
      @tbmsahil8850 Pƙed měsĂ­cem

      @@manasjena5124 I a study platform so I am not saying anything but oversmart bna sa Tera Ghar nhi chalega

  • @girdhar3224
    @girdhar3224 Pƙed rokem

    crisppp

  • @m.kaviyarasanshan789
    @m.kaviyarasanshan789 Pƙed rokem

    Why if (i>=maxReach) explain in English mam

  • @user-gq1ij
    @user-gq1ij Pƙed 2 lety

    wont work for the array 2,1,1

  • @laxmidawane7892
    @laxmidawane7892 Pƙed 2 lety

    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

    • @Lokesh-po5jr
      @Lokesh-po5jr Pƙed 2 lety

      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

  • @growmore1672
    @growmore1672 Pƙed 2 lety

    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.

  • @mayankjoshi8888
    @mayankjoshi8888 Pƙed 3 lety

    Striver bhaiya ki sheet ke question bhi solved kijiye plz

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 3 lety +2

      Hi Mayank, actually striver is solving that sheet, but kafi common ques hai, I will cover them. Thank you for suggesting. :)

    • @mayankjoshi8888
      @mayankjoshi8888 Pƙed 3 lety

      @@AyushiSharmaDSA ohk thanks😊💯

  • @SHASHANKRUSTAGII
    @SHASHANKRUSTAGII Pƙed 2 lety +1

    Better than the Code explainer. I was fed up of this stupid voice. Good work

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety +1

      Thank you :) glad it was helpful

    • @SHASHANKRUSTAGII
      @SHASHANKRUSTAGII Pƙed 2 lety

      @@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.

  • @deepakkumarthakur8429
    @deepakkumarthakur8429 Pƙed 2 lety

    The fumbles in between the explanation creates a lot of confusion.😣

  • @jivanninawe3190
    @jivanninawe3190 Pƙed 2 lety

    Mam hindhi may padho na recurion 😁

  • @akshaycodex9568
    @akshaycodex9568 Pƙed 8 měsĂ­ci

    badhya bateye laiken manna padga

  • @anilph6389
    @anilph6389 Pƙed rokem +1

    not good

  • @deepakkumarthakur8429
    @deepakkumarthakur8429 Pƙed 2 lety

    10:04 9+8 is 18 (mistake)

  • @ravindrayadav6103
    @ravindrayadav6103 Pƙed rokem

    chatgpt se chaap diya

  • @harishreddythalla
    @harishreddythalla Pƙed 2 lety

    9+8=18 at 10:03 😂

  • @chillmaccha6392
    @chillmaccha6392 Pƙed 2 lety

    Can u please explain in English

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety

      Hi, Sure, this was old video, new videos are in English :)

  • @praneeth871
    @praneeth871 Pƙed 4 měsĂ­ci

    Referal milegaa kya

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 4 měsĂ­ci +1

      Zaroor milega, job id Aur resume bhejo linkedin pe

  • @karthikmamidishetti2528
    @karthikmamidishetti2528 Pƙed 2 lety +2

    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.

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety +1

      Hey, sure think, usually in my videos, I show code at end only. :)

  • @hemesh5663
    @hemesh5663 Pƙed 2 lety +1

    could you explain i >= maxreach condition if possible

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety

      If current index becomes greater than maxreach, then it means that we got minimum jumps

    • @hemesh5663
      @hemesh5663 Pƙed 2 lety

      @@AyushiSharmaDSA so why are we returning -1 then

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety

      @@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

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Pƙed 2 lety

      Dry run once with a test case

    • @hemesh5663
      @hemesh5663 Pƙed 2 lety

      @@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