Это видео недоступно.
Сожалеем об этом.

DP 4. Frog Jump with K Distance | Lecture 3 Follow Up Question

Поделиться
HTML-код
  • Опубликовано: 10 янв 2022
  • Lecture Notes/C++/Java Codes: takeuforward.o...
    Problem Link: atcoder.jp/con...
    Make sure to join our telegram group for discussions: linktr.ee/take...
    Pre-req for this Series: • Re 1. Introduction to ...
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we have discussed how to solve the frog jump problem with K distance allowed. I have taught you how you should write a 1D recurrence. This problem is a follow-up to Lecture 3's follow-up question.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.o...
    You can also get in touch with me at my social handles: linktr.ee/take...

Комментарии • 2 тыс.

  • @takeUforward
    @takeUforward  2 года назад +310

    I need your support, and you can do that by giving me a like, and commenting "understood" if I was able to explain you.

    • @abhishek_Gupta25
      @abhishek_Gupta25 2 года назад +2

      Leetcode contest 275 solution????

    • @rox_official9407
      @rox_official9407 2 года назад

      Sir can we solve this question same as frog jump with i-1 to 1-2 one where you solved that question with tabulation method ...
      What i want to say can we code this too as same as that one ?

    • @takeUforward
      @takeUforward  2 года назад +1

      @@rox_official9407 Yes that only i have explained here

    • @alokkumar-ki7wp
      @alokkumar-ki7wp 2 года назад

      US

    • @vamsikrishnaravinuthala6699
      @vamsikrishnaravinuthala6699 2 года назад

      nice explanation bro super🤗

  • @mrbeast00000
    @mrbeast00000 2 года назад +183

    I wrote the full code without seeing this video and it is exactly matching yours .Considering I have watched just 3 of your videos and I have started figuring out myself is amazing .You are DP King for me striver .Thanks for providing us with this much value packed content.

    • @KalpitJain13.3
      @KalpitJain13.3 Год назад +3

      Same Bro I also wrote same code

    • @tylerd5924
      @tylerd5924 7 месяцев назад +2

      Same here just used one less variable.😅 And got it in first run 🤯

    • @anshusorrot316
      @anshusorrot316 4 месяца назад

      Same bro

    • @gauravkondhare3605
      @gauravkondhare3605 4 месяца назад +1

      Same thing happened with me for his recursion series!

    • @saitejageddada3109
      @saitejageddada3109 2 месяца назад +1

      @@KalpitJain13.3 dengey

  • @davidmwangi4312
    @davidmwangi4312 10 месяцев назад +4

    This is the best DP series I have come across, simple and precise after perusing several other tutorials on DP. Thank you Striver

  • @user-cz2pj2ct4p
    @user-cz2pj2ct4p Год назад +4

    Understood Completely. I watched the L3 yesterday and was figuring out in mind about the followup and by my own came up with the logic of looping and the (i-j>=0) conditions. Started building logic myself. Thanks Striver

  • @anushkachakraborty8635
    @anushkachakraborty8635 Год назад +28

    I just realised to explain us all the codes, he actually manually writes all the codes with digital pen.
    Which is so so much tougher than actually typing the code.
    Big hats off.

  • @ScienceSeekho
    @ScienceSeekho 2 года назад +41

    For those who need basic code to start of this question
    #include
    using namespace std;
    int helper(int n, int k, vector &heights) {
    if(n == 0) return 0;
    int minSteps = INT_MAX;
    for(int j=1; j= 0)
    l = helper(n-j, k, heights) + abs(heights[n] - heights[n-j]);
    minSteps = min(minSteps, l);
    }
    return minSteps;
    }
    int frogKJump(int n, int k, vector &heights) {
    return helper(n-1, k, heights);
    }
    int main(){
    vector heights;
    heights = {10, 20, 30, 10};
    cout

  • @sangeethagopalan301
    @sangeethagopalan301 2 месяца назад +2

    THE BEST DP Series. UNDERSTOOD :)

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 Год назад +7

    Understood I just can't express My happiness that I am able to solve this question in all 3 ways(Recursive ,memoization , tabulation) Myself. Its just all because of You❤

  • @parthsalat
    @parthsalat 2 года назад +56

    Pseudocode at 6:43
    Complexity analysis at 8:14
    Memoization at 7:15
    Tabulation at 10:15

  • @MrPrakash219
    @MrPrakash219 2 года назад +41

    "UNDERSTOOD"
    DEAR STRIVER,
    PLEASE TAKE CARE OF YOUR HEALTH.

  • @justcode......2254
    @justcode......2254 9 месяцев назад +2

    thanks man for providing such a mindblowing content without charging even a single penny.Hats off to you

  • @perfect_man6263
    @perfect_man6263 3 месяца назад +4

    its literally after 2 years ,but still the best content in the internet so far :) "UNDERSTOOD":D

  • @kartiksuman9814
    @kartiksuman9814 2 года назад +11

    US... Thankyou sooo sooo much bhaiya for taking so much pain for us, even when you were not well. At first when I started watching this video, then I did feel that your voice was not having that zeal that you have in all your previous videos, and in the end, you made me right...nevertheless, take good care of yourself.

  • @twinklebajaj5461
    @twinklebajaj5461 2 года назад +15

    UNDERSTOOOOOOD ! you doing a great job ! And I am so so proud of you !
    Take love !

  • @vibhavsharma2724
    @vibhavsharma2724 3 месяца назад +1

    Thanks striver for this excellent explanation.

  • @doctorkael6049
    @doctorkael6049 3 месяца назад

    Understood! I have been religiously watching all of your Striver A2Z DSA video series. The efforts and dedication that you've put into making these videos are themselves so inspiring. 98 more videos to go!

  • @defensiveespeon7734
    @defensiveespeon7734 Год назад +6

    For the space optimization, use a LIFO queue with size K with arbirtrary access.

  • @blurrybrush1010
    @blurrybrush1010 2 года назад +3

    was able to do it competely by myself yesterday as you didnt uploaded the video.Take care of yourself!!

  • @user-bt6mh9ez3u
    @user-bt6mh9ez3u Месяц назад

    Very informative and actually the best series ..thanks a lot sir

  • @harshthakur6251
    @harshthakur6251 5 месяцев назад +1

    bro i'm following up your a to z dsa course this is superb i usually do not comments but here i forced to because your content is ultimately superb thank you for it

  • @anubhavpabby8158
    @anubhavpabby8158 2 года назад +3

    Thank you Striver Bhaiya, I got the grasp of concepts & understood all the concepts taught in this video

  • @dharmeshpoladiya9047
    @dharmeshpoladiya9047 2 года назад +4

    Understood 💯💯 Great Explanation. Thank you very much for all you efforts🔥🔥

  • @kumaranuj03
    @kumaranuj03 10 месяцев назад +1

    Hey today is 30-09-2023 I am watching this lecture. I can not resist myself from completing this awesome playlist as soon as possible.
    Thanks @takeUforward for this awesome playlist.

  • @nandhakrishna2330
    @nandhakrishna2330 10 месяцев назад +2

    Striver ,the way you teach is really exceptional ✨

  • @pool477
    @pool477 2 года назад +15

    Please add leetcode link in description so that we can attempt it before the video starts.
    Consider this request

    • @champion5946
      @champion5946 2 года назад +3

      bhai link de to rkha
      dikhta nhi h kya
      ye question AtCoder pe h
      thoda leetcode ki jindagi se bhar nikal

    • @pool477
      @pool477 2 года назад

      @@champion5946 kyu bhai leetcode se kya dikkat hai

    • @champion5946
      @champion5946 2 года назад +4

      @@pool477 mene bola dikat h?
      frog 1 & 2 AtCoder ka question h
      secondly wo banda videos bana rha h
      or link bhi wohi dhundke de tumhe 😂😂

    • @pool477
      @pool477 2 года назад

      @@champion5946 😂😂

  • @aryanagrawal4794
    @aryanagrawal4794 2 года назад +3

    Wonderfully explained, really appreciate your effort bhaiya, UNDERSTOOD.

  • @NirmalyaMusicOfficial
    @NirmalyaMusicOfficial Месяц назад

    Understood. Appreciate your efforts 💯

  • @vikrammehra4354
    @vikrammehra4354 2 месяца назад +1

    understood bhaiya thanku 💖

  • @kandhalkhandeka5938
    @kandhalkhandeka5938 Год назад +3

    Highly appreciate the efforts for this playlist!!

  • @verizon2851
    @verizon2851 2 года назад +6

    Thanks a lot Striver! your explanation is too good 🔥🔥

  • @MukeshKumar-cc3uh
    @MukeshKumar-cc3uh 6 месяцев назад

    "Understood". Thank you for the clear explanation in the earlier lectures, I solved this question in all ways(recursive, memoization and tabulation and even the space optimized one) even before watching the video. ♥

  • @omkarkathile1249
    @omkarkathile1249 Месяц назад

    Excellent teaching Understood sir 🔥❤‍🔥❤‍🔥

  • @gautomagarwal6039
    @gautomagarwal6039 2 года назад +5

    understood! loving this series lately.

  • @prantikofficial
    @prantikofficial 2 года назад +6

    understood !!
    crystal clear

  • @ishitagupta4074
    @ishitagupta4074 День назад

    "US"- Thankyou so much

  • @spiral546
    @spiral546 17 дней назад

    space optimized version:-
    int minimizeCost(vector& arr, int& k) {
    // Code here
    int n = arr.size();
    vector dp(k, 1e9);
    dp[0] = 0;
    for(int ind =1; ind

  • @sdeBack1
    @sdeBack1 2 года назад +7

    By using priority queue , The time complexity reduced to O (N * log(k) ) , space - O(k)

    • @verma_jay
      @verma_jay Год назад +4

      No, you still have to push the K values inside the priority queue, so time will actually increase to O(N * KlogK)

  • @kr_ankit123
    @kr_ankit123 2 года назад +3

    Incase you find it difficult to code for optimized space that is O(k)
    int frog_k_dp_opt(int n,vector &arr,int k){
    vector dp(k+1,0);

    for(int i=1;i

  • @lalitbisht8381
    @lalitbisht8381 7 дней назад

    Had fun watching this❤

  • @jaishriharivishnu
    @jaishriharivishnu Месяц назад

    DP and recursion... both are quite like magic for me

  • @rohan8758
    @rohan8758 3 месяца назад +1

    understood Raj bhaiyan, your surnames(Vikramaditya) suits to your reality, because you breain is full of knowledge!

  • @anujrathore5726
    @anujrathore5726 Месяц назад

    Thank you striver , for this amazing dp series , i did this que by myself .

  • @vinaylj
    @vinaylj Месяц назад

    US
    Nice explanation Striver

  • @user-gf9mw5in7l
    @user-gf9mw5in7l 2 месяца назад

    understood sir, thanks for such clear and concise explanations, hats off to you.

  • @user-el6hv6em7m
    @user-el6hv6em7m Месяц назад

    understood !!!
    thanks for this amazing DP series...

  • @jagansubramanian5234
    @jagansubramanian5234 8 месяцев назад

    I am able to think I the code immediately without seeing the solution. Thank you Striver for the good Dp series

  • @vaishnavimore4860
    @vaishnavimore4860 Год назад +1

    Understood! Truly amazing series✨ Just by watching first two videos able to start thinking approach for further problems!! Thank you Striver bhaiyya for making DSA easier for us🚀

  • @stith_pragya
    @stith_pragya 7 месяцев назад

    UNDERSTOOD............Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @shrutichouksey1324
    @shrutichouksey1324 16 дней назад

    UNDERSTOOD BHAIYA

  • @itsAbh15hek
    @itsAbh15hek 9 дней назад

    understood perfectly

  • @MIRAZIB
    @MIRAZIB Год назад +2

    at 8:00. What is the time complexity of only recursive (no Memoization) approach.
    Is it --> O(k^n).

  • @themysticalman9390
    @themysticalman9390 11 месяцев назад +1

    Understood , keep up the good work

  • @rakeshbasak6842
    @rakeshbasak6842 4 месяца назад

    Understood vaiya... plz don't stop making videos

  • @manasansh7198
    @manasansh7198 10 месяцев назад

    Understood man REally hats off to you great effort

  • @771aryan
    @771aryan Год назад

    in the space optimisation part, instead of carrying a list, we can carry an array of k size such that every time when a new element's dp needs to be stored : we store it at the dp[index % k] position. This will overwrite the existing value in the dp array.
    So the code in java will look like:
    dp[0] = 0;
    for(int index = 1; i

  • @sakthilakshmim5008
    @sakthilakshmim5008 8 месяцев назад

    Understood Striver! Thank you so much for this amazing series.

  • @ritikshandilya7075
    @ritikshandilya7075 2 месяца назад

    Thankyou so much Striver , great explanation

  • @animestuff144
    @animestuff144 7 дней назад +1

    Understand

  • @user-cl3un2qx7s
    @user-cl3un2qx7s 7 месяцев назад +1

    understood !

  • @harihardhik3293
    @harihardhik3293 6 дней назад

    UNDERSTOOD SIR

  • @prabhakaran5542
    @prabhakaran5542 6 месяцев назад +1

    Understood ❤

  • @ishaaandatta908
    @ishaaandatta908 3 дня назад

    Understood
    If k was guaranteed smaller than N, it still wouldn't make sense to perform space optimisation due to the O(N) right shift required for array deletion and addition right?

  • @pranjaledits_007
    @pranjaledits_007 10 дней назад +1

    Understood

  • @ankitsen6490
    @ankitsen6490 2 месяца назад +1

    Understood!

  • @abhisheknemade2444
    @abhisheknemade2444 8 месяцев назад

    Thanks Bhaiya. Very nice explaination to this problem. Understood.

  • @hetvishah9123
    @hetvishah9123 Год назад

    Understood!!! You’re doing a great job for us. It’s helping us a lot. ThankYou so much

  • @ipshitatandon5134
    @ipshitatandon5134 Месяц назад

    Understood! thank you sir :)

  • @surbhirathore._
    @surbhirathore._ Месяц назад +1

    Understood!!

  • @sharda16april
    @sharda16april 6 месяцев назад

    Understood Striver, thank you.

  • @shubhamkumarsingh8818
    @shubhamkumarsingh8818 Месяц назад +1

    understood

  • @SelvaArumugam-xq5mf
    @SelvaArumugam-xq5mf 8 месяцев назад

    Great vedio bhaiyaa understood

  • @sameerpal3526
    @sameerpal3526 10 месяцев назад +1

    Thanks Men! Hare Krishna

  • @sunilkumar-jf8bt
    @sunilkumar-jf8bt 5 месяцев назад

    Thank you for the outstanding content.

  • @minhthang93
    @minhthang93 Год назад

    the tabulation is not work, right? I try it and it not calculate the last index of dp[] because condition in second loop
    j so it will not calculate it and always return 0

  • @mahithareddysai5457
    @mahithareddysai5457 Год назад

    Time complexity for recursive solution is O(k^n)
    Right!!

  • @anshikagupta5858
    @anshikagupta5858 9 месяцев назад

    Thankyou Striver for all your efforts, great explanation :)

  • @Sanya-ic8gr
    @Sanya-ic8gr 2 месяца назад

    UNDERSTOOD!!!!

  • @chaitrabhat8199
    @chaitrabhat8199 8 месяцев назад

    Much Appreciated Striver

  • @studynewthings1727
    @studynewthings1727 10 месяцев назад +1

    code for space optimization:
    def k_jumps(n,arr,k):
    dp = [0 for i in range(k)]
    if n == 0:
    return 0
    for index in range(1,n):
    result = 999999
    for i in range(1,k+1):
    if (index > (i - 1)):
    step = dp[k-i] + abs(arr[index] - arr[index-i])
    else:
    step = 9999999
    result = min(result,step)
    dp.remove(dp[0])
    dp.append(result)
    print(dp)
    return dp[k-1]
    arr = [30,10,60,10,60,50]
    n = len(arr)
    k = 3
    result = 999999
    print(k_jumps(n,arr,k))

  • @radharamamohanakunnattur3035
    @radharamamohanakunnattur3035 Год назад

    Understood, wondeerful lectures!! A Big Big Thank You

  • @viro-jx2ft
    @viro-jx2ft Год назад

    #UNDERSTOOD! NO DOUBT THE BEST SERIES OF DYNAMIC PROGRAMMING.

  • @23souravkushwaha8
    @23souravkushwaha8 4 месяца назад

    understood. thank you for your efforts sir

  • @user-ot1rd8hd3d
    @user-ot1rd8hd3d 11 месяцев назад

    understood bhaiya thank you so much
    you are getting blessings of so much ppl
    this level of content at no cost

  • @varunrkolur
    @varunrkolur 10 месяцев назад +1

    Understood!!
    I wrote 7 different meathod for the same problem, Amazing!!!.

  • @wahabshaik6843
    @wahabshaik6843 2 месяца назад

    understood bro take care of u

  • @KartikeyTT
    @KartikeyTT 15 часов назад

    tysm sir

  • @lifehustlers164
    @lifehustlers164 5 месяцев назад

    5/57 done!!! Understood!

  • @hashcodez757
    @hashcodez757 20 дней назад

    "UNDERSTOOD!!"

  • @Halfdimension1263
    @Halfdimension1263 5 месяцев назад +1

    Understood :)

  • @snipper6683
    @snipper6683 3 месяца назад

    UNDERSTOOD

  • @ammumddhareppagol4898
    @ammumddhareppagol4898 17 дней назад

    Understood ☺️

  • @no_name45689
    @no_name45689 Месяц назад

    Understood.

  • @GeneralistDev
    @GeneralistDev Год назад

    Was able to solve without watching the video all 3 approach

  • @user-to3jj8lj8h
    @user-to3jj8lj8h Месяц назад

    "understood !"

  • @Anonymous-hj4zh
    @Anonymous-hj4zh 2 месяца назад

    Thank you! Understood:)

  • @Sarthak-u8v
    @Sarthak-u8v 19 дней назад

    Understood 🤘🤘

  • @anuplohar23
    @anuplohar23 9 месяцев назад

    Hats Off to your efforts 😊❤‍🔥❤‍🔥

  • @harshvardhan1214
    @harshvardhan1214 5 месяцев назад

    Wow , did I just cracked a DP problem myself by only watching 3 videos.. Hail! Striverrrrr

  • @genzScarlet
    @genzScarlet 27 дней назад

    UNDERSTOOD :)

  • @Nisita-sp8hs
    @Nisita-sp8hs 2 месяца назад

    understood sir.