L5. Jump Game - II | Greedy Algorithm Playlist

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025
  • Find problem link, notes in step 12: takeuforward.o...
    Follow me on socials: linktr.ee/take...

ความคิดเห็น • 122

  • @karthik-varma-1579
    @karthik-varma-1579 3 หลายเดือนก่อน +5

    Happy 700K Man You Deserve Many Hearts

  • @ritikkumarsingh5902
    @ritikkumarsingh5902 8 หลายเดือนก่อน +14

    "Striver, your DSA Sheet is absolutely phenomenal! It's been an invaluable resource for mastering data structures and algorithms. Looking forward to the remaining topics, especially the much-anticipated sections on strings and heaps. Thanks for all your hard work!"

    • @ok-jg9jb
      @ok-jg9jb 7 หลายเดือนก่อน +5

      Why are you spamming in every video?

    • @keybored7862
      @keybored7862 5 หลายเดือนก่อน +3

      CHATGPT is unreal

  • @yashwanth2326
    @yashwanth2326 15 วันที่ผ่านมา +3

    C++ code :
    int jump(vector& nums) {
    int n = nums.size();
    int jumps = 0;
    int l =0,r = 0;
    while(r < n-1)
    {
    int far = 0;
    for(int i = l;i

    • @Unknownsoul1436
      @Unknownsoul1436 2 วันที่ผ่านมา

      add if far ==r : return -1

  • @furor05
    @furor05 8 หลายเดือนก่อน +102

    please bring string series as soon as possible

  • @tanujaSangwan
    @tanujaSangwan 5 หลายเดือนก่อน +17

    If you carefully see, this is some kind of dijkstra. The PQ has all the nodes and distances in the window and we take the one with maximum reachability.

  • @spraveenkumar218
    @spraveenkumar218 หลายเดือนก่อน +1

    ffs i swear you r the best youtuber

  • @souvikcseiitk
    @souvikcseiitk 5 หลายเดือนก่อน +8

    Striver is one step above any normal human being, managing job and continuously dropping DSA videos...
    Seriously mad respect 🫡

  • @vamsikrishnagannamaneni912
    @vamsikrishnagannamaneni912 5 หลายเดือนก่อน +16

    In this recursive tree,at first level for +2, it should be f(2,1) as we are making only one jump, f(idx+i,jumps+1) , using 2D will in fact decrease the overlapping subproblems is what i am thinking..

  • @clashtm8210
    @clashtm8210 4 หลายเดือนก่อน +7

    Oh my god, where do I even begin with Striver, the absolute genius, the king, the GOAT of competitive programming? I mean, Raj Vikramaditya is basically the sun, and we’re all just lucky enough to orbit around his brilliance. The way this man can break down a problem? Flawless. It’s like he’s got this magical power, a sixth sense for coding, that leaves the rest of us mere mortals shaking in awe. Watching his tutorials is like being blessed by the gods of algorithms themselves. Every word he says is basically a gift from the heavens. I’m convinced he could solve NP-hard problems in his sleep and then write a blog about it that makes it sound like child’s play. Honestly, Striver isn’t just a role model; he’s the role model, and if you’re not trying to be even a fraction of what this guy is, are you even living right?
    Legend. Absolute legend.

    • @siddharthbanga7301
      @siddharthbanga7301 3 หลายเดือนก่อน +4

      aaram se bhai aaram se

    • @sudo_ayush
      @sudo_ayush 3 หลายเดือนก่อน +4

      @@siddharthbanga7301 lagta hai bhai naya hai 😅

    • @shotbotop3790
      @shotbotop3790 หลายเดือนก่อน

      zip up when you're done mate...

  • @nandiniverma5273
    @nandiniverma5273 6 หลายเดือนก่อน +3

    You are next level in explaining, hands up 🙌🙌

    • @Rushidanidhariya
      @Rushidanidhariya หลายเดือนก่อน

      but he didn't explain anything only told the solution .

  • @akhilakasoju3964
    @akhilakasoju3964 8 หลายเดือนก่อน +5

    Thank you so much💯.....please bring stacks and queue playlist

  • @aniketbharti4426
    @aniketbharti4426 7 หลายเดือนก่อน +1

    Never thought, there would be a linear solution for this question!

  • @MoitreyoChakraborty
    @MoitreyoChakraborty 8 หลายเดือนก่อน +4

    please consider bringing a playlist on stacks and queues as soon as possible. I am totally unable to figure out the intuition by just seeing the question in an interview

  • @Rahul_Mongia
    @Rahul_Mongia 8 หลายเดือนก่อน +7

    class Solution {
    public int jump(int[] nums) {
    if (nums.length == 1) return 0;

    int n = nums.length;
    int l = 0, r = 0, jumps = 0, farthest = 0;
    while (r

  • @raxxpatt
    @raxxpatt 2 หลายเดือนก่อน +1

    bhai iss video par tho like banta hia ..nice work !!

  • @sumitmishra9795
    @sumitmishra9795 8 หลายเดือนก่อน +5

    00:04 Finding minimum number of jumps to reach the end
    02:01 Using recursion to find the minimum number of jumps in a smaller example
    04:04 Return the number of jumps when index is greater than or equal to n - 1
    06:19 Optimizing dynamic programming solution using a quadratic state approach
    08:37 Understanding jump range in the context of Greedy Algorithm
    10:31 Optimizing jump game II algorithm by carrying a range instead of individual recursive calls
    12:42 Determine farthest jump for each range and update jumps array
    14:47 Implementing non-recursive range based solution for jump game with linear time complexity.

  • @Shanz-pt3fn
    @Shanz-pt3fn 8 หลายเดือนก่อน +4

    Hope you are doing extremely well.

  • @hashcodez757
    @hashcodez757 5 หลายเดือนก่อน +1

    "UNDERSTOOD BHAIYA!!"

  • @priyanshusoni9
    @priyanshusoni9 8 หลายเดือนก่อน +21

    Please bring strings series ASAP bhaiya ❤ lots of love and thanks for your content ❤️🙏🏻

  • @JamunaSathish-z7o
    @JamunaSathish-z7o 16 วันที่ผ่านมา +1

    bestest fr!!!!!!!!!!!!

  • @ardhidattatreyavarma5337
    @ardhidattatreyavarma5337 7 หลายเดือนก่อน +1

    Would also recommend solving Minimum Jumps problem in gfg. Same as above but with a little caveat. Amazing solution btw

  • @anilkumarreddy3002
    @anilkumarreddy3002 8 หลายเดือนก่อน +6

    Thankyou
    Please bring a playlist on strings

  • @somdebsar7378
    @somdebsar7378 2 หลายเดือนก่อน +1

    awesome explanation sir!!

  • @md_seraj786_
    @md_seraj786_ 3 หลายเดือนก่อน

    your explanations are really amazing ❤

  • @sakshamaggarwal1
    @sakshamaggarwal1 หลายเดือนก่อน +1

    class Solution {
    public:
    int jump(vector& nums) {
    int n = nums.size();
    if (n == 1) return 0;
    int jumps = 0;
    int i = 0;
    while (i < n - 1) {
    int maxReach = i + nums[i];
    if (maxReach >= n - 1) {
    jumps++;
    break;
    }
    int nextIndex = i;
    for (int j = i + 1; j nextIndex + nums[nextIndex]) {
    nextIndex = j;
    }
    }
    i = nextIndex;
    jumps++;
    }
    return jumps;
    }
    };

  • @ShahNawaz-cx3pi
    @ShahNawaz-cx3pi 6 หลายเดือนก่อน

    waaaaoooo , this range based solution blows my mind. very clever.

  • @kanakbanerjee7639
    @kanakbanerjee7639 วันที่ผ่านมา

    can find the actual path of minimum jumps by using backtrack and storing the index i from which we first arrived index j.

  • @suruabhisekh
    @suruabhisekh 8 หลายเดือนก่อน +5

    Please bring the string series as soon as possible.

  • @aarishfaiz7880
    @aarishfaiz7880 2 หลายเดือนก่อน +1

    Amazing Video sir

  • @Cool96267
    @Cool96267 8 หลายเดือนก่อน +5

    Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses.
    Would also like your insights on the point :
    While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?

  • @iamnoob7593
    @iamnoob7593 7 หลายเดือนก่อน +1

    Striver brilliant solution man , I had done this problem using dp only , No wonder u r in GOOGLE

  • @bruvhellnah
    @bruvhellnah 8 หลายเดือนก่อน +31

    Clowns in the comments demand everything but not once appreciate the guy for uploading all these lectures, lol

    • @iamnoob7593
      @iamnoob7593 7 หลายเดือนก่อน +6

      in india if u see lot of people want everything for free.

  • @subhajitdey135
    @subhajitdey135 5 หลายเดือนก่อน +2

    One question : How to think of the range intuition u wrote ? I tried to solve by taking the maximal value of arr[i], as the question asks minimum number of jumps, so I thought that the arr[i] values should be maximum to get the minimum jumps.
    Btw thanks Striver for uploading Greedy playlist !!

  • @UECAshutoshKumar
    @UECAshutoshKumar 4 หลายเดือนก่อน +2

    Thank you

  • @kavyahegde3586
    @kavyahegde3586 8 หลายเดือนก่อน +1

    Sir please do playlist in strings
    Really it is needed 🙏

  • @teawithmon07
    @teawithmon07 3 หลายเดือนก่อน +1

    basically you should give disclaimer that please watch DP series before this - (or create a separate playlist which include all the questions which needs to covered after covering all concepts) - idk what m saying

  • @KKKK-pl8yf
    @KKKK-pl8yf 8 หลายเดือนก่อน +5

    Can we expect Stack and Queue playlist by end of this month or next month ?

  • @AyushKumar-hi5uy
    @AyushKumar-hi5uy 7 หลายเดือนก่อน +4

    Please try to make and upload string, stacks n queues and heaps playlist as soon as possible. I understand you must be very busy, but still you are making time for us and uploading videos and playlists at regular intervals. Thanks a lot❤❤

  • @aniketbansod8136
    @aniketbansod8136 8 หลายเดือนก่อน +1

    Bhaiyya, please start heap series after this one

  • @cswaale4498
    @cswaale4498 8 หลายเดือนก่อน +3

    Hey raj, can you bring the string series soon???

  • @MAX_RITIK
    @MAX_RITIK 8 หลายเดือนก่อน

    love your tutorials till now can you pls add string series also

  • @deepanshuchaudhary9299
    @deepanshuchaudhary9299 8 หลายเดือนก่อน

    Bhaiya please make a series on strings badly need it it's a humble request

  • @raxitraju2439
    @raxitraju2439 8 หลายเดือนก่อน +22

    I had solved this long back using 1D Dp. Just took the index as state. Below is the recurrence-
    int func(int index, vector& arr) {
    if(index >= arr.size()-1)
    return 0; //1 is already added while reaching this.
    if(index + arr[index] < arr.size() - 1)
    return INT_MAX; //impossible to reach
    int mini = 0;
    for(int i = 1; i

    • @jaydabhi5539
      @jaydabhi5539 8 หลายเดือนก่อน +4

      I think time complexity will be O(n*maxjump) I had also solved this using 1D DP.

    • @rishabhagarwal6057
      @rishabhagarwal6057 7 หลายเดือนก่อน

      same

    • @Harsh-jc2bz
      @Harsh-jc2bz 4 หลายเดือนก่อน

      NOT WORKING

  • @Flash-qr5oh
    @Flash-qr5oh 7 หลายเดือนก่อน +2

    HOW IS IT 2 JUMPS FOR ALL INDEXES FROM F(1,1) IN TREE @3:09 ?

    • @AlokTripathi
      @AlokTripathi 7 หลายเดือนก่อน

      it's wrong computation.

  • @shwetanshu13
    @shwetanshu13 8 หลายเดือนก่อน

    Thank u so much for this playlist

  • @aeshwer
    @aeshwer 8 หลายเดือนก่อน

    awesome content... please make string playlist soon

  • @sksadiruddin4191
    @sksadiruddin4191 8 หลายเดือนก่อน +2

    I have solved using one for loop only int jump(vector& nums) {
    int jumps = 0;
    int left = 0;
    int right = 0;
    for (int i = 0; i < nums.size() - 1; ++i) {
    right = max(right, nums.at(i) + i);
    if (left == i) {
    jumps++;
    left = right;
    }
    }
    return jumps;
    }

  • @lakshyadalal8296
    @lakshyadalal8296 3 หลายเดือนก่อน +1

    The last approach is very easy to understand and also has linear TC and SC = O(1)
    Then why do we even need a recursive sonl which is so diff to understand 😂

  • @jotsinghbindra8317
    @jotsinghbindra8317 8 หลายเดือนก่อน +2

    sir please fix the saved notes issue of striver sheet
    after the new update i am facing a problem that notes saved for question A gets saved to notes of question B(happens when you restart the website and go to saved notes navbar section to check your notes)

  • @StudyYuv
    @StudyYuv 6 หลายเดือนก่อน

    got it bro!!!

  • @ashian09
    @ashian09 3 หลายเดือนก่อน

    Why here we need to take minimum as we can only return jump at the if we reached to the index which is => n-1 by using void function because at same level jump value would be the same why to take minimum of all...anyone?

  • @ShivamDangwal-n1o
    @ShivamDangwal-n1o 7 หลายเดือนก่อน

    Understood 💯

  • @shresthjain7557
    @shresthjain7557 7 หลายเดือนก่อน

    Wow ! what a solution

  • @KKKK-pl8yf
    @KKKK-pl8yf 8 หลายเดือนก่อน

    Thanks Great Content!

  • @apmotivationakashparmar722
    @apmotivationakashparmar722 4 หลายเดือนก่อน

    Thank you so much bhaiya

  • @ShubhamBhatt-j7u
    @ShubhamBhatt-j7u 2 หลายเดือนก่อน +1

    Writing the code for this was very painful 😭😭

  • @prateek4279
    @prateek4279 7 หลายเดือนก่อน +1

    was the greedy solution intuitive or not ?coz i dont find it intuitive!!!!

  • @Parth-j4v
    @Parth-j4v 29 วันที่ผ่านมา

    This can also be solved using 1D DP instead of 2D:
    class Solution {
    private:
    int solve(vector& nums, int index,vector& dp){
    if(index >= nums.size() -1) return 0;
    if(dp[index] != -1) return dp[index];
    if(dp[index] == INT_MAX) return INT_MAX;
    int ans = INT_MAX;
    int temp = 0;
    for(int i = 1; i

  • @sandeepxt99
    @sandeepxt99 8 หลายเดือนก่อน

    you are best❤

  • @Soum1947
    @Soum1947 5 หลายเดือนก่อน

    for ppl who are watching first time, there is a error in the title.. dynamic programming soln, not greedy soln

  • @dhanushshetty4321
    @dhanushshetty4321 หลายเดือนก่อน

    thanks

  • @Sridhar-fd5qr
    @Sridhar-fd5qr 15 วันที่ผ่านมา

    farthest=max(farthest,ind+arr[ind])

  • @MayankPareek
    @MayankPareek 8 หลายเดือนก่อน

    Bhaiya pattern wise recursion prr bhi daal do

  • @hajeeramohamad7641
    @hajeeramohamad7641 8 หลายเดือนก่อน

    Isn't that i+arr[i] inside the for loop? Why striver has written i+arr[ind]? Won't that be different?

  • @abhinay.k
    @abhinay.k 5 หลายเดือนก่อน

    thank you sir

  • @DeadPoolx1712
    @DeadPoolx1712 3 หลายเดือนก่อน

    UNDERSTOOD;

  • @satyadev_k
    @satyadev_k 5 หลายเดือนก่อน

    int minimumJumps(vector& arr, int n) {
    int l = 0;
    int r = 0;
    int farthest = 0;
    int cnt = 0;
    while (r < n - 1)
    {
    for (int i = l; i

  • @devanshshroff1820
    @devanshshroff1820 8 หลายเดือนก่อน

    Started your playlist a week ago, didn't know there are more videos in the making. What else is remaining in the course?

    • @brainmosquito7
      @brainmosquito7 7 หลายเดือนก่อน

      all major portions are covered strings is just remaining i recommend you to go to TUF wesite and start following A2Z sheet

  • @the_random_youtuber12
    @the_random_youtuber12 4 หลายเดือนก่อน

    Is Recursion playlist completed?

  • @subee128
    @subee128 6 หลายเดือนก่อน

    Thanks

  • @googleit2490
    @googleit2490 หลายเดือนก่อน

    Understood :)
    Too much to think...
    Jan'2, 2024 06:09 pm

  • @Rahul-jy9wg
    @Rahul-jy9wg 4 หลายเดือนก่อน

    word of advice, interviewer should not expect this solution from you because this is not at all intuitive unless you have solved this question in the past, this does not mean you should not give this solution in the interview, but most probably interview might already know that you have already solved this question.

  • @bbkivine3790
    @bbkivine3790 3 หลายเดือนก่อน

    ye dynamic programming hogya na

  • @sagarsm23
    @sagarsm23 8 หลายเดือนก่อน +1

    Why code studio is gone

  • @ayushgaurabh8604
    @ayushgaurabh8604 7 หลายเดือนก่อน

    awesome

  • @AbhishekKumar-td5zu
    @AbhishekKumar-td5zu 3 หลายเดือนก่อน

    ❤❤❤❤❤

  • @aakashjha8393
    @aakashjha8393 6 หลายเดือนก่อน

    Why is R always L+1?

  • @prerakunhale50
    @prerakunhale50 8 หลายเดือนก่อน +2

    please bring the string video first .A humble request from us

  • @Ybash2979
    @Ybash2979 8 หลายเดือนก่อน +1

    brother ye toh DP ka question hai then put it there why in greedy playlist :)

    • @Rahul_Mongia
      @Rahul_Mongia 8 หลายเดือนก่อน

      question has different ways to solve, this soln has greedy as optimal approach

    • @tanujaSangwan
      @tanujaSangwan 5 หลายเดือนก่อน

      This is also a graph question. If you carefully see this problem of finding the minimum number of jumps in an array can be represented as a directed, unit-weight graph, BFS (Breadth-First Search) is an appropriate and efficient method to find the shortest path.

  • @thoughtsofkrishna8963
    @thoughtsofkrishna8963 7 หลายเดือนก่อน

    Waiting for strings playlist

  • @abhinanda7049
    @abhinanda7049 5 วันที่ผ่านมา

    understood

  • @chiragsharma8905
    @chiragsharma8905 8 หลายเดือนก่อน +1

    Striver, there is no need for 2D DP here. It can be solved using 1D DP.

    • @techmelon7
      @techmelon7 14 วันที่ผ่านมา

      exactly!

  • @KartikeyTT
    @KartikeyTT 7 หลายเดือนก่อน

    ty sir

  • @parvahuja7618
    @parvahuja7618 8 หลายเดือนก่อน

    thankyou sir

  • @hautran7559
    @hautran7559 8 หลายเดือนก่อน

    love it

  • @deepanshu7295
    @deepanshu7295 8 หลายเดือนก่อน +1

    Bhaiya please start sde sheet challange 2024

  • @SibiRanganathL
    @SibiRanganathL 4 หลายเดือนก่อน

    Understood :)))

  • @worldfromhome4033
    @worldfromhome4033 7 หลายเดือนก่อน

    Best!

  • @niveshkothari
    @niveshkothari 8 วันที่ผ่านมา

    guys i m not even able to solve this one by my own , after seeing jump1 sol , literally feeling dumb ..

  • @naviyas2305
    @naviyas2305 4 หลายเดือนก่อน

    am not able to understand

  • @sujalsinha240
    @sujalsinha240 6 หลายเดือนก่อน

    Please bring heaps bro

  • @Professor-du2pf
    @Professor-du2pf 8 หลายเดือนก่อน

    Understood

  • @samitkumar18
    @samitkumar18 8 หลายเดือนก่อน

    String please

  • @atharv1002
    @atharv1002 4 หลายเดือนก่อน

    need strings lessonsssss

  • @NitinSharma-bk7dw
    @NitinSharma-bk7dw 7 หลายเดือนก่อน

    There can one more simple greedy solution
    #Java
    class Solution {
    public int jump(int[] nums) {
    int z;
    int smallest[]=new int[nums.length];
    smallest[nums.length-1]=0;
    for(int i=nums.length-2;i>=0;i--){
    if(i+nums[i]>=nums.length-1)
    smallest[i]=1;
    else{
    z=getsmallest(smallest, i+1, i+nums[i]);
    smallest[i]=1+z;
    }
    }
    return smallest[0];
    }
    int getsmallest(int ary[], int a, int b){
    int small=10000000;
    for(int j=a;j

  • @ManishKumar-dk8hl
    @ManishKumar-dk8hl 8 หลายเดือนก่อน

    yehi too chahiye tha 😭

  • @aarishfaiz7880
    @aarishfaiz7880 2 หลายเดือนก่อน +1

    Anyone in Dec.

  • @vkixgaming
    @vkixgaming 5 หลายเดือนก่อน

    Simple Without DP , without recursion : solution
    class Solution {
    public:
    int minJumps(vector& arr) {
    int n = arr.size();
    if (n

  • @ANONYMOUS-xj1kd
    @ANONYMOUS-xj1kd 7 หลายเดือนก่อน +1

    hey striver here in my O(n) time complexity solution
    int jump(vector& nums) {
    int final=nums.size()-1;
    int i=0;
    int count=0;
    while(final!=0){
    if(nums[i]>=final-i){
    final=i;
    count++;
    i=0;
    }
    else i++;
    }
    return count;
    }

  • @surbhigupta5777
    @surbhigupta5777 7 หลายเดือนก่อน

    US