Jump Game (LeetCode 55) | Full solution with animations and visuals | Greedy Algorithms

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 103

  • @namanpande7644
    @namanpande7644 11 місяців тому +7

    This is actually a very good explanation. I was able to understand because of the dry-run of the code. Thanks a lot.

  • @yomamasofat413
    @yomamasofat413 4 місяці тому +4

    man every question like this just feels so exhausting. It's either some kind of trick or hack to solve the problem.

  • @meghan6819
    @meghan6819 9 місяців тому +4

    Your solutions and explanations are great!! thank you

  • @chandankumar-ip5hf
    @chandankumar-ip5hf 2 місяці тому

    directly went into my head, able to write code after dry run explanation

  • @arupgope2676
    @arupgope2676 7 місяців тому

    your explanation is great. I have tried many dsa channels to follow. Then I find this channel. It is so great and underrated.

  • @suyashrahatekar4964
    @suyashrahatekar4964 Рік тому +2

    underrated channel

  • @shwetakumari-ms2xg
    @shwetakumari-ms2xg Рік тому +2

    watching your video for the first time, really liked your explanation. Would watch more of your videos :) thanks!

    • @nikoo28
      @nikoo28  Рік тому

      Glad you like them!

  • @nexonsensei3793
    @nexonsensei3793 9 місяців тому

    I watched so many videos n i could not understand the problem , after watching your video i finally understood it🥺🔥 the visualisation helped alot to understand

  • @nandinideshpande1467
    @nandinideshpande1467 5 місяців тому

    your explanation was very simple. made me understand the problem.

  • @nagendravelpuri444
    @nagendravelpuri444 Рік тому

    For this problem i seen many videos, but this one was crystal clear and i never forget.
    Very Good Job Sir.

  • @srikanthchebrolu1091
    @srikanthchebrolu1091 Рік тому +5

    I'm fan of ur way of teaching
    I learnt trees because of u
    Hope you start dp playlist like trees
    please ♥️😇

  • @ABDULKALAM-ig2dd
    @ABDULKALAM-ig2dd Рік тому +2

    Sir I am big fan of your leetcode playlist, Regularly folllowing it ,Please continue doing more videos on leetcode ,Waiting for more Leetcode problems ❤

    • @nikoo28
      @nikoo28  Рік тому +2

      i am adding more and more problems when I get time. Trying to cover important problems first :)

    • @ABDULKALAM-ig2dd
      @ABDULKALAM-ig2dd Рік тому

      @@nikoo28 🤍

  • @ankitchaurasiya529
    @ankitchaurasiya529 7 місяців тому

    Just Wow...
    I understand after watching first time this video.

  • @akashvijayasarathy6234
    @akashvijayasarathy6234 9 місяців тому

    this is a gem of a video.

  • @surenderreddy6294
    @surenderreddy6294 6 місяців тому

    fantastic brilliant,explanation sir,you deserve a lot

  • @arslanmuhammad4190
    @arslanmuhammad4190 Рік тому +1

    Hi Sir, You are gem. I am learning from you a lot. Thanks, Sir for this Help.

  • @JagadeeswarN-ur7of
    @JagadeeswarN-ur7of 21 день тому

    Great Explanation..thanks!!

  • @Iam_Srikanth_009
    @Iam_Srikanth_009 4 місяці тому

    It was really a clean and clear explanation ❤

  • @satyam_28
    @satyam_28 10 місяців тому

    Cool explanation bhai...and an advice...keep content concise and outro subtle

    • @nikoo28
      @nikoo28  10 місяців тому

      i try my best, but everyone has their own learning pace. for quick learners, i have chapter markers for faster navigation 😄

  • @sravansunkara
    @sravansunkara 3 місяці тому

    Excellent solution

  • @usmanrangrez-cd7zj
    @usmanrangrez-cd7zj Рік тому +1

    class Solution {
    public:
    bool canJump(vector& nums) {
    int n=nums.size();
    int maxJump=0;
    for(int i=0;imaxJump)
    return false;
    maxJump = max(maxJump,i+nums[i]);
    if(i>=n-1)
    return true;
    }
    return false;
    }
    };

  • @shresthgupta2670
    @shresthgupta2670 16 днів тому

    Thanks sir love your intuition building 😍

  • @catsadogga1651
    @catsadogga1651 6 місяців тому

    your explanation is super

  • @tejas5331
    @tejas5331 9 місяців тому

    i like how you explain with Animation

  • @Ayushkumar-co9mc
    @Ayushkumar-co9mc 8 місяців тому

    Best explanation ever

  • @abhyudaysingh3381
    @abhyudaysingh3381 4 місяці тому

    Best Explaination 👍

  • @bipinsingh1490
    @bipinsingh1490 Рік тому

    Bhai quality explaintaion h apka great baki UA-cam channel toh bs code padh dete h intuition toh batate v nhi h

    • @nikoo28
      @nikoo28  Рік тому

      i like to focus on the problem solving, rather than the language. Languages will come and go. 😅, logic will stay

  • @Justforfun-u7j
    @Justforfun-u7j 3 місяці тому

    perfect explantion

  • @workHolic-ne6eo
    @workHolic-ne6eo Рік тому

    thats the video i was searching exactly

  • @jamesk6884
    @jamesk6884 10 місяців тому +1

    amazing explanation, love the video.
    this is my algorithm before watching ur video, it only passed 120/170 test cases when i tried to submit it. So i just wanted to know if my approach to this question is definitely incorrect.
    class Solution {
    public boolean canJump(int[] nums) {
    int size = nums.length-1;
    int sum = 0;
    for (int i=0; i < nums.length-1; i++){
    sum += nums[i];
    }
    if (sum-(nums.length-2)>= size){
    return true;
    } else if (nums[0]>= nums.length-1){
    return true;
    } else{
    return false;
    }
    }
    }
    again, thx for the video

  • @tanishkaagarwal6750
    @tanishkaagarwal6750 Рік тому

    sir your explaination is awesome... keep uploading more videos.

    • @nikoo28
      @nikoo28  Рік тому

      thanks for your feedback, keep watching :)

  • @rambhaktuchihaobito7987
    @rambhaktuchihaobito7987 8 місяців тому +1

    thank u sir ... for such a great explanation❣❣

  • @Paradox82827
    @Paradox82827 8 місяців тому

    Very good explaination!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @MadpolygonDEV
    @MadpolygonDEV Рік тому +2

    Incredible presentation as always. Would love to have you do a problem solving mindset tips and tricks.

    • @nikoo28
      @nikoo28  Рік тому

      that is a really great idea, I will add it to my pipeline of upcoming videos

  • @kunalkheeva
    @kunalkheeva Рік тому

    Dry run really helped! thanks a tonne!

  • @gauravjain969
    @gauravjain969 Рік тому

    Awesome explanation 🔥

  • @arjitgautam365
    @arjitgautam365 10 місяців тому +1

    really helpful. Thanks a lot!

  • @sagniksaha4179
    @sagniksaha4179 2 місяці тому +1

    Explanation is awesome 💯. But i was thinking is it possible to think this soln in an interview. The very first thing came to my mind was recursion. I found this while i was going through the discussion section of leetcode. Any advices on how to think this type of soln in an interview. Any suggestion is appreciated

    • @philj9594
      @philj9594 18 днів тому

      The only real answer is to grind these problems over and over. Just like a math class, the best way to get good is extreme repetition of practice problems. Also, sometimes you just won't get the problem in your interview and you need to focus on the next one and realize that this is normal and to not be discouraged. If you do enough problems to where you can solve even 10% of them easily and quickly, then you are able to get a job if you just get lucky enough to have those 10% of problems in your interview.

  • @amitshukla2268
    @amitshukla2268 Рік тому

    Very nice explanation, thanks, keep it up :)

  • @LetsGo-ro1iq
    @LetsGo-ro1iq 8 місяців тому +1

    Great Video

  • @raghavachekuri7270
    @raghavachekuri7270 Рік тому

    outstanding explination plz try to do playlist for DP ur explination is 🥳

    • @nikoo28
      @nikoo28  Рік тому

      I have a playlist on DP. Constantly adding more and more problems to it: ua-cam.com/play/PLFdAYMIVJQHPXtFM_9mpwwQtIdzP6kxHS.html

  • @amitshukla2268
    @amitshukla2268 Рік тому +1

    Please add your chair also in your Recording Gear? Did you buy it from amazon ?

    • @nikoo28
      @nikoo28  Рік тому

      Links in the description :)

    • @amitshukla2268
      @amitshukla2268 Рік тому

      @@nikoo28 i didn't find it.

    • @nikoo28
      @nikoo28  10 місяців тому

      Chair is from Autonomous.

  • @КарэнАкопьян
    @КарэнАкопьян Рік тому

    Thank you for your work!

  • @Karan9.9
    @Karan9.9 11 місяців тому

    very nice and clear explanation thanks !!!

    • @nikoo28
      @nikoo28  11 місяців тому

      Glad it was helpful!

  • @mahadishakkhor123
    @mahadishakkhor123 9 місяців тому

    i understand from u

  • @shubhamkumar-hx1fb
    @shubhamkumar-hx1fb 11 місяців тому

    i really hate kind of videos which doesnt tells the intuition why we are doing so.....there are many videos avl for this pblm and many of them are just doing the dry run of the code without telling the intuition behind their though process....
    But i am really thanks to you sir that you focused more on the intuition behind the code and have not just done the dry run 😌😌

    • @nikoo28
      @nikoo28  10 місяців тому

      glad you liked it

  • @Krishnasagars22
    @Krishnasagars22 3 місяці тому

    Great!! Thanks a lot

  • @jk-sm6qr
    @jk-sm6qr 8 місяців тому

    Nice explaination, Thank you

    • @nikoo28
      @nikoo28  7 місяців тому +1

      You are welcome

  • @КарэнАкопьян
    @КарэнАкопьян Рік тому

    Thank you, you helped me so much!

    • @nikoo28
      @nikoo28  Рік тому

      You're very welcome!

  • @abhishekomprakash4074
    @abhishekomprakash4074 Рік тому

    Super useful.💯

  • @abhinavprasad2828
    @abhinavprasad2828 Рік тому

    Okay so, I don't usually comment but yeah this video was great.

    • @nikoo28
      @nikoo28  11 місяців тому

      Thank you so much

  • @MeghaVerma-n9k
    @MeghaVerma-n9k 2 місяці тому

    Osm explanation thnks

  • @Shhhh-ni5jw
    @Shhhh-ni5jw 8 місяців тому

    With this approach, we never stop on the 0’s right? We are checking if somehow we are able to bypass

  • @hamdasalam4373
    @hamdasalam4373 5 місяців тому

    could you please create a video for leetcode 2483?

  • @paridhishrivastava9133
    @paridhishrivastava9133 Рік тому

    thankyou so much sir its too good

  • @taslimarahmanprema8643
    @taslimarahmanprema8643 Рік тому +1

    Best one

  • @murugesh1915
    @murugesh1915 6 місяців тому

    Nice content

  • @subhashreesahoo5760
    @subhashreesahoo5760 7 місяців тому

    Hi.. Thanks for the vide, your explanation is really good and helpful.
    But I do have doubt here and a request while explaining , pls consider the code also .
    I feel like the explanation and the dry run code somewhere I am unable to understabnd(may be I need more practice but still..)
    Example-> while explaining you said to go back step from 1 , that is 0, you cant reach the destination => agree
    but in dry run code-> idx+nums[idx] , how are you bringing these terms, like how did you think its should be in this way , its like idx=7,nums[7]=0 and you are adding both 7+0=7, so i am not getting how your idea is to add idx+nums[idex].

    • @nikoo28
      @nikoo28  7 місяців тому

      If you have understood the explanation, try to write the code on your own. That is the only way you will learn. If everything else fails, only then refer to someone else’s code.

    • @subhashreesahoo5760
      @subhashreesahoo5760 7 місяців тому

      @@nikoo28 ok sure, Thank you, I will take your advice and implement the same.

  • @subee128
    @subee128 11 місяців тому +1

    Thanks

  • @Mr.NothingSpecial
    @Mr.NothingSpecial 9 місяців тому

    You're basically looking for the last reachable index at each iteration. That is not a greedy approach. Can you explain what do you mean by greedy approach?

    • @nikoo28
      @nikoo28  9 місяців тому

      My greed is that I want to reach the last pointer from where I am standing

  • @TraySoek
    @TraySoek Рік тому +1

    brilliant

  • @saisree04
    @saisree04 6 місяців тому

    Thanks a ton

  • @gurudassulebhavikar
    @gurudassulebhavikar Рік тому +1

    You could have used your Jump Game 2 solution here. Both problems are almost same.

  • @filmbuzz9419
    @filmbuzz9419 Рік тому

    Take a value and show it by dry run so we understand a bit more Thanks

  • @SibiRanganathL
    @SibiRanganathL 3 місяці тому

    Understood

  • @nguyenhoanthien4277
    @nguyenhoanthien4277 3 місяці тому

    great!

  • @nehakanki1606
    @nehakanki1606 10 місяців тому

    Got itt👍

  • @AshishKumar-x5l8s
    @AshishKumar-x5l8s 9 місяців тому

    Its O(N**2) ?? Can anyone explain in case of DP

    • @nikoo28
      @nikoo28  9 місяців тому

      why do you want a solution with a poor time complexity?

  • @razataggarwal7365
    @razataggarwal7365 Рік тому +3

    Why we are calling optimal solution as greedy algorithm ?
    My perspective :
    If I see it, we have optimized our Iterative DP (Tabulation) by going to every index from last to first and asking if i can reach target or not.

  • @DigvijayKirti
    @DigvijayKirti 10 місяців тому

    What if the second last element is zero?
    Let's dry run the provided array [3, 2, 1, 0, 4] through the given canJump method:
    Dry run:
    Initial State: lastElement = 4 (index of the last element).
    Iteration 1 (i = 3):
    i + nums[i] = 3 + 0 >= 4, which is less than lastElement. No update.
    Iteration 2 (i = 2):
    i + nums[i] = 2 + 1 >= 4, which is less than lastElement. No update
    Iteration 3 (i = 1):
    i + nums[i] = 1 + 2 >= 4, which is less than lastElement. No update
    Iteration 4 (i = 0):
    i + nums[i] = 0 + 3 >= 4, which is less than lastElement. No update
    Return: lastElement == 0, which is true.
    So, for the array [3, 2, 1, 0, 4], the canJump method returns true, indicating that it is possible to jump from the first element to the last element.
    Please explain I'm not able to understand the false case?

    • @nikoo28
      @nikoo28  10 місяців тому

      you need to start from the last element, not the first one. watch the explanation that starts at 9:17

  • @pkeditsff8405
    @pkeditsff8405 Місяць тому

    I didn't understand your code 😢😢😢😢

    • @philj9594
      @philj9594 18 днів тому

      This problem is pretty advanced if you are relatively new to coding. I'm at the end of a college-level data structures course and they included this problem in the homework and the professor even admits that most people at our level will not be able to solve these leetcode 150 problems and he said you are on the right track if you can at least come up with an idea of how to solve the problems that he is giving us.
      My point is, if you are just completely lost, that just means you need to look at easier problems and work your way up to this. I promise you that this will make sense later on if you just don't give up. You need to be working at your current level. Even though I understand this code, there are many where I wouldn't understand just like you. Look up the "zone of proximal development" and try to find out where your zone currently is and just work within there. Your experience here is perfectly normal and expected. Don't be ashamed if you have to go back to the very basics of coding for awhile.

  • @singhvishal8794
    @singhvishal8794 10 місяців тому +2

    i actually tried this code and come across a wrong ans for [1] as it is reachable at any cost so i run the loop from nums.length -1 to 0 and that worked.... and thank you for this amazing solution i stuck on this for 3 hrs straight...