DP 24. Rod Cutting Problem | 1D Array Space Optimised Approach

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024

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

  • @takeUforward
    @takeUforward  2 ปีที่แล้ว +283

    We completed DP on Subsequences, can you solve any question now on this topic :P

    • @AnilKumar-bv5sr
      @AnilKumar-bv5sr 2 ปีที่แล้ว +5

      Thanks for the content, high on confidence

    • @rechinraj111
      @rechinraj111 2 ปีที่แล้ว +11

      I m having 10+ yrs of experience in JAVA. I guess it's sufficient for us also. Before leaving India would u be able to complete DP series? Kindly don't leave in-between.

    • @sirajkhan0825
      @sirajkhan0825 2 ปีที่แล้ว

      Definitely Yes!!!

    • @yashroy7436
      @yashroy7436 2 ปีที่แล้ว +7

      Can the Lecture Notes be updated from DP-16 onwards? It is a something which makes your series unique from other creators, as it makes revision also much more easy! :)

    • @takeUforward
      @takeUforward  2 ปีที่แล้ว +16

      @@yashroy7436 sure, let m give u the link: takeuforward.org/dynamic-programming/striver-dp-series-dynamic-programming-problems/

  • @RangerDivine
    @RangerDivine 2 ปีที่แล้ว +151

    Before I started watching your series on dp and recursion, my brain wasn't able to process recursion, so I completely avoided it. But your daily dose of dp is certainly changing that. Your content is no doubt good, but your energy is on a different level.

    • @sagartaak4017
      @sagartaak4017 ปีที่แล้ว +1

      TRUTH

    • @AshishKumar-ww1mr
      @AshishKumar-ww1mr ปีที่แล้ว +7

      now dp is all about writing recursion and after that its just a cake walk

    • @dpxy1599
      @dpxy1599 ปีที่แล้ว +1

      @@AshishKumar-ww1mr exactly if you can write the recursive brute force solution correctly then it's just a cake walk.

  • @sandeeperukulla498
    @sandeeperukulla498 2 ปีที่แล้ว +119

    Hey Striver, I did the problem in all 4 approaches including 1D Array space optimization without watching the video. Your videos helped me a lot. Thanks, Striver. This is the best DP series out there.

    • @apratimdutta2223
      @apratimdutta2223 ปีที่แล้ว +14

      Your comment may be very satisfying for striver but he will also feel he lost some watch minutes!

    • @Anonymous_Coder
      @Anonymous_Coder ปีที่แล้ว

      @@apratimdutta2223 Even after solving there is always something new that you always get from his videos .

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

      🤣🤣@@apratimdutta2223

  • @kazuma0803
    @kazuma0803 2 ปีที่แล้ว +24

    I can do questions I even feared to read now in just 10 minutes. Thanks a lot, Striver.

  • @amanbhadani8840
    @amanbhadani8840 2 ปีที่แล้ว +13

    I already solved this question with all 4 approaches upto space optimization with 1 array before watching this video.This dp on subsequence part is running in our veins now.

  • @the-tech-jerry
    @the-tech-jerry 8 หลายเดือนก่อน +5

    Just completed the dp on subsequence section and literally by the end I could solve the problem without looking at the video and skipping the recursion part itself. Outstanding job of compliling and explaing the dp process. So many DP lectures, blog posts out there but none of them covers the core idea of how the tabulation itself is achieved. Most of them consider tabulation as a totally different approach and make it magical instead of teaching it as an optimization step after recursion which makes it difficult to approach. Keep up the good work we need more people like you 👍the cherry on top is its free of cost ❤❤❤.

  • @scharmilahruthika250
    @scharmilahruthika250 6 หลายเดือนก่อน +4

    I just have 2 days to learn DP. I am super thankful for my brother to suggest this. Now I am confident enough to solve problems. The way you teach from breaking down the problem statement to building up solution step by step is such a bliss. I was so confused looking at solutions on internet which would straight away be the space optimised. At times I couldn't understand why would take dp[n][target+1] length. All these confusions had built up anxiety and dp seemed allergic. Now I can sayyyyy DP IS FUN! Thanks Striver!!

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

    Before I started watching your series on dp and recursion, my brain wasn't able to process recursion, so I completely avoided it. But your daily dose of dp is certainly changing that. Your content is no doubt good, but your energy is on a different level.

  • @kunalsaha9239
    @kunalsaha9239 2 ปีที่แล้ว +20

    Your dp series is Marvelous.
    For me yes now I can able to solve dp problem atleast i can come up with the recursive steps quickly.
    But some times the base case part (specially thinking of base case part in tabulation is tricky)
    But I am quite sure that with practice I will make it good.
    Thank you so much for your efforts ❤️❤️

  • @vatsalkudecha2746
    @vatsalkudecha2746 2 ปีที่แล้ว +10

    I code all 4 solutions - recursion -> memoisation -> tabulation -> space-optimisation even before starting this video.....That's the confidence and knowledge one gets by following Raj bhaiya's DP series....Kuddos to you.... Raj bhaiya.....

    • @sshuk2307
      @sshuk2307 2 ปีที่แล้ว +1

      Could you please share the link or notes here as well.

    • @sarthakvaish2520
      @sarthakvaish2520 2 ปีที่แล้ว

      🙌

  • @shlok1124
    @shlok1124 ปีที่แล้ว +5

    This is an outstanding DP series. Even if you overlook your dedication to come up with 4 ways to solve 1 question in every video. Thanks for this.

  • @vineetsingh4707
    @vineetsingh4707 7 หลายเดือนก่อน +3

    I have seen people saying that they struggle with DP a lot and this was my first time studying DP literally you made it so easy for me you made me so confident like just throw any question at me till now and i would do it for you to the last possible optimization thanks for this masterpiece and as always UNDERSTOOD everything.

  • @arijitdas4560
    @arijitdas4560 2 ปีที่แล้ว +2

    UNDERSTOOD......After this I went to leetcode and trying doing problem on dp on subsequences ....I had sloved almost every by my own except some problems ...Thanks for bringing this ,I really don't know how to express my gratitude towards you.

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

    Hey Striver, I did the problem in all 4 approaches including 1D Array space optimization without watching the video. Your videos helped me a lot. Thanks, Striver. This is the best DP series out there.❤❤

  • @anandkalpe2155
    @anandkalpe2155 ปีที่แล้ว +3

    Understood !!!
    Literally man, what are you ! You just made it very very easy with your concepts, approaches, clean and short codes. Simply Great !!!
    And not to miss, You converted fear to joy smoothly :)
    Hats off to you man !!!

  • @DevRathi-gl7gs
    @DevRathi-gl7gs 2 หลายเดือนก่อน +2

    Thank you so much striver after watching this series i am enough confident that i can solve any question on subsequence pattern

  • @pranjalthapliyal2278
    @pranjalthapliyal2278 ปีที่แล้ว +4

    Understood :)
    Been doing all the problems on my own for the last 10 problems or so, your content (and especially its ordering) is genuinely incredible

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

    UNDERSTOOD sir, Thanks for this amazing series.

  • @chitranshjain5075
    @chitranshjain5075 2 ปีที่แล้ว +1

    Thank you Striver! Successfully solved using all the 4 approaches by myself without watching the video. It's all because of you. A few months back I was afraid of DP and now I feel the most confident in DP, all thanks to you!

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

    after watching all the above videos , I was able to solve this question on my own completely. Thanks a lot

  • @user-is6ky7pp2n
    @user-is6ky7pp2n 17 วันที่ผ่านมา +2

    Understood !! Hey striver i solved this on my own with all aproaches. Thanks you are awesome !!

  • @udaypratapsingh8923
    @udaypratapsingh8923 ปีที่แล้ว +1

    *with all three approaches*
    *approach1: recursion*
    int solve(int n , vector prices)
    {
    if(n == 1) return prices[0];
    if(n == 0) return 0;
    int maxi = INT_MIN;
    for(int length = 1 ; length

  • @rishabhkalra9505
    @rishabhkalra9505 2 ปีที่แล้ว +11

    Surprisingly, a similar variant was asked to me in 1st round of Microsoft interview

  • @shubhankarsharma154
    @shubhankarsharma154 ปีที่แล้ว +2

    Now I'm confident enough to say that I can solve any question on DP on Subsequences... Thank you so much Striver .. 🔥🔥
    Forever Grateful🙇

  • @santanu29
    @santanu29 ปีที่แล้ว

    Opened the video just to get the problem link. I got stuck in the take condition, but then did the rest till 1D array all by myself. Thank you for the great lectures.

  • @paramsratanpal6551
    @paramsratanpal6551 2 ปีที่แล้ว +1

    Previously when i tried to solve this problem ,i was stuck,but today i was able to solve it in 1d space without even watching the vid,amazing content bro

  • @parthsalat
    @parthsalat 2 ปีที่แล้ว +11

    *Code timestamps*
    Recursion: 12:15
    *Complexities*
    Recursion and memorization: 13:35

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

    You are the best Striver! I totally enjoyed DP on Subsequences, a topic I feared a lot, but now it has become a topic that I enjoy and solve. Understood it because of your awesome way of teaching, thank you bhaiya!!!

  • @karthikravi2781
    @karthikravi2781 2 ปีที่แล้ว +2

    Your DP series is extremely great!! Hats off for your effort!!

  • @gaganvishwakarma6494
    @gaganvishwakarma6494 ปีที่แล้ว +1

    I listen the problem and just remove the weight array from the fractional knapsack code as simple as that . All Thanks to striver.

  • @YajingLiu-cl4tp
    @YajingLiu-cl4tp 6 หลายเดือนก่อน

    Thank you!! Your videos truly help me!! When I listen to my professor's lectures, I find it difficult to keep up with the professor's pace most of the time. But when I watch your videos, I can easily follow up. And after watching your video, I can use the same strategy to solve different dp problems.

  • @saimanojporeddy6938
    @saimanojporeddy6938 ปีที่แล้ว +2

    Hii striver ,
    I used same code we did for unbounded knapsack .Instead of weights vector I created a vector of size n whose value of each index =index+1 and then I passed it. It worked perfectly🤩. And more importantly I did this before watching this video😊😊.
    Thank you.

  • @im_kishanpandey
    @im_kishanpandey ปีที่แล้ว

    Honestly speaking, I feared after I saw any DP problem, and now after coming this far I can write the tabulation code all in the first step... All thanks to this wonderful course by striver..

  • @ayanangshudasmajumder112
    @ayanangshudasmajumder112 ปีที่แล้ว +1

    Understood entire DP on subsequence!!! Feels like i can make my own questions on this topic.

  • @codewithyou311
    @codewithyou311 2 ปีที่แล้ว +2

    After viewing from starting to till 3 min. i have solved this problem from recursion to space optimization. :)

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

    Recursion, Memoization, Space Optimization, and 1D array optimization ALL BY MYSELFFFF!!!!!.
    THANK YOUUUU STRIVERRRRR!!!!! YOU'RE THE BEST TEACHER EVERRR!!!!!!
    DP ON SUBSEQUENCES EASYYYY PEASSYYY LEMON SSQUEAZZYYYY!!!!!!!! 💯💯💯💯💯

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

    Now, after watching Striver Bhaiya's DP series, I can solve any problems from DP.

  • @jaividyasagarr7110
    @jaividyasagarr7110 ปีที่แล้ว

    Understood! Dp became cake walk for me only because of you. Thanks a lot. Very grateful to you.

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

    Understood! Since you've already explained these concepts so well in the previous problem, I was able to solve it on my own. Thanks, Striver! 💯

  • @itsaryanb9316
    @itsaryanb9316 ปีที่แล้ว

    I was only confused with the base cases of this problem, had watched the lecture till recursion part, but solved this problem using all the 4 methods including 1-D Space optimised tabulated approach, all thanks to you Striver❤

  • @gkm0.150
    @gkm0.150 2 ปีที่แล้ว

    Previously I found many difficulties in DP but after following your DP series I feel comfort in DP
    Without seeing this video I solve this question only by your approach... in previous Question
    thanks a lot sir and I think this is one of the best DP series....

  • @rohitraj5832
    @rohitraj5832 2 ปีที่แล้ว

    No one has expalined approach to his problem so well. keep growing and giving amazing contents.

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

    I ain't watching the videos for the approaches , with just a little consistency of less than 2 weeks i'm able to solve most of the problems until now. I still came here to write on this video because i think bhaiya you deserve to know this how awesome playlist you've created. God bless you and your family ❤

  • @aagamjain2131
    @aagamjain2131 ปีที่แล้ว +3

    You made me feel confident in DP
    And yes, UNDERSTOOD 🔥

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

    ..may be u never see this comment but striver you are really a god gifted person.....i was afraid of dp on subseq , after doing all your lectures i am able to write recursive as well as easily memoize it for hard and unseen problems.....thank you than you sooo much❤❤❤❤...

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

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

  • @MukeshKumar-cc3uh
    @MukeshKumar-cc3uh 5 หลายเดือนก่อน

    This series provides immense clarity on the concepts ❤. DP on sub-sequences felt like a cakewalk.
    Thank you and Understood.👍

  • @hardikjain6397
    @hardikjain6397 2 ปีที่แล้ว +1

    wonderful series it is, completed this question in 4 minutes without watching the video.

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

    solved this problem in all the ways without watching this video🤩Striver bhaii🔥

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

    Was able to solve via all 4 approaches without watching the video thank you so much for the playlist.

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

    FInally solved Question without watching video , thanku man.

  • @rishabhgupta9846
    @rishabhgupta9846 ปีที่แล้ว +1

    understood,able to solve by myself.After mapping it to 0/1 Knapsack ,it was cakewalk.But mapping it to 0/1 Knapsack currently is easy as I'm solving DP subsequence problem right now.But in future mapping and remembering will be most important part.

  • @jeelanibasha3984
    @jeelanibasha3984 29 วันที่ผ่านมา

    You are extremely great i have solved all 3 approaches on my own 🎉

  • @splinkerp2222
    @splinkerp2222 2 ปีที่แล้ว +2

    Bhaiya your couse is a premium course. Thanks for giving us it for free. Very thankful to you 😊

  • @vishnubanjara5209
    @vishnubanjara5209 ปีที่แล้ว +1

    This playlist is created for build a confidence in every student that he can do anything with coding

  • @rajharsh3739
    @rajharsh3739 10 หลายเดือนก่อน +2

    Solve this without seeing solution . i have to say that i m loving the process 🔥🔥. BTW bhaiya , many many congrats for getting promoted to SWE 3 at Google . 😃😃

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

    understood and able solve the problem on my own
    int cutRod(vector &price, int n)
    {
    // Write your code here.
    vectordp(n+1, 0);
    dp[0] = 0;
    for(int N=1; N

  • @maruthibabutirupati2583
    @maruthibabutirupati2583 ปีที่แล้ว

    Understood from recursion to 1D array optimization. Thank you so much for your awesome series.

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

    Understood striver! through your teaching way, it is easy getting into dp day by day, it's because of you only Striver❤✨

  • @user-hn9ox6py4p
    @user-hn9ox6py4p 6 หลายเดือนก่อน

    without watching the solution, i solved it by my self , thank u striver

  • @Coder-zz1tn
    @Coder-zz1tn 4 หลายเดือนก่อน

    I have started to solve the problems by myself, thanks to you bro

  • @generationtech4350
    @generationtech4350 ปีที่แล้ว +1

    The best dp playlist available in the market. Before this i had confusion whether to continue with love babbar or start strivers do. Best decision i've made for a while.

  • @ishaanchandak4774
    @ishaanchandak4774 ปีที่แล้ว

    did this question myself . thanks a lot . i was not proficient with solving these kinda questions but now they seem easy .thanks a lot

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

    exact same code of unbounded knapsack passes
    thanks striver 👍👍

  • @udatyadeb101
    @udatyadeb101 ปีที่แล้ว

    understood ! was able to solve the problem all by myself till 1d space optimization.

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

    Thank you so much for posting very good quality lectures on data structures. It is very much helping in preparing for my dream job

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

    Your DP Series is extremely of Next Level

  • @nsmworldentertainment4687
    @nsmworldentertainment4687 ปีที่แล้ว

    I hope I will be able to solve any question in this pattern. Understood all problems taught so far. Thank you very much. Its just time to practice now.

  • @iamb92
    @iamb92 ปีที่แล้ว +1

    Hello Striver, your videos have been very useful to me and my research project (I am facing a lot of optimization problems). I've already had experience in solve DP problems, but your approach definitely take me forward =), regards!.

  • @sayandey2492
    @sayandey2492 ปีที่แล้ว

    Never knew Rod Cutting problem is just Unbounded Knapsack with Rod length = Knapsack capacity; Price of each piece = Profit of items ; Length of each piece = Weight of items....simply fabulous 🤯

  • @TanishqAnand
    @TanishqAnand 2 ปีที่แล้ว

    After watching these videos I am able to solve the problems till 2array space optimization by myself!!!!! kudos to striver!!!!

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

    You make dp on subsequences so so easy..... really you are great.... ❤❤❤

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

    Bhai ..your dp series is damn amazing it is one of the best dp playlist in the world ...where you cover each and everything

  • @AshishKumar-ww1mr
    @AshishKumar-ww1mr ปีที่แล้ว

    I am still not able to believe that I am not scared of DP anymore, in fact pretty confident in it. Thanks striver bhiaya !!!

  • @adityasaxena6971
    @adityasaxena6971 ปีที่แล้ว

    Done this question by all 4 approaches ,Thanks Striver

  • @NAVEENKUMAR-uj7xe
    @NAVEENKUMAR-uj7xe 2 ปีที่แล้ว

    Thanks for providing these important series with full effort.
    Hope many like me would take benefit of it

  • @johar3737
    @johar3737 ปีที่แล้ว

    Understood. Many Many Thanks Sir. Your teaching style is absolutely awesome.

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

    for those who are thinking why we are making recursive call with same index again and again when we pick it , its a small logic.
    In previous questions of dp on subsequences, we had constraint that if we pick an index then it cannot be picked again in calculating that particular answer (particular branch if you think it by drawing recursion tree).
    since in this question we are allowed to take same length even more than 1 time , that is why rather than going to
    previous index we try to check if the curr length can be again cut off from the rod.
    eg- N=10 and idx=4 i.e rod length= 5 , so we will check for length =5 and then rather than going to check for length =4 , we will check if we can cut length=5 again , since it is allowed to cut multiple same lengths.
    and we cannot cut same length more than once , simply "not take" will go ahead and continue the flow of recursive calls

  • @satwikaadusumilli7534
    @satwikaadusumilli7534 ปีที่แล้ว

    This is my first ever comment in your playlist. I was able to do the question myself. I significantly see a definite change in me. Thank u sooo mucchh striver🥰. I understood dp only becoz of u.

  • @shuvo9131
    @shuvo9131 2 ปีที่แล้ว

    Yes I got the confidence that dp on subsequence is easy topic now. Thank for the awesome series.

  • @pulkitjain5159
    @pulkitjain5159 ปีที่แล้ว

    knapsack wali se hi hojayega ,koi code mein change karne ki jaroorat nahi , bas array of wieghts ko index+1 se initialise kardo aur kaam khatam. learnt a lot from this series , uski wajah se hi maximum question ho paa rahe hai

  • @sanginigupta1312
    @sanginigupta1312 2 ปีที่แล้ว +1

    Completed! I feel very confident now

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

    Understood Striver !! Cheers 🎉

  • @kotipallimadhumeher71
    @kotipallimadhumeher71 2 ปีที่แล้ว +1

    happiness is when u r doing the dp on your own😁😁
    thnks striver bhaaii !!!

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

    Summary: convert the problem to unbounded knapsack
    N -> capacity of bag
    Rod lengths (which are (ind + 1) of given array) -> weights of elements
    Prices -> Values

  • @sanchitbhadgal4303
    @sanchitbhadgal4303 2 ปีที่แล้ว

    I can't believe bro, Done the question without the video. Thanks Alot Striver.

  • @shripandey4120
    @shripandey4120 ปีที่แล้ว

    amazing...today is diwali and I am watching your videos.

  • @lohitaksha244
    @lohitaksha244 2 ปีที่แล้ว +1

    Understood, Loved your approach to dp in general.

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

    Yes.... Now i can solve any problem on DP on sub-sequence

  • @balwantyadav724
    @balwantyadav724 2 ปีที่แล้ว +1

    yea now I can any questions on subsequences. Thanks a lot sir...

  • @tejashwinibadi9984
    @tejashwinibadi9984 2 ปีที่แล้ว

    Understood.
    Thank you so much.
    I was able to figure out the logic on my own for this problem.

  • @dipaligangawane980
    @dipaligangawane980 2 ปีที่แล้ว

    Thank you so much Striver for wonderful lectures on DP.

  • @shivanshumishra0560
    @shivanshumishra0560 ปีที่แล้ว

    understood sir !!! and yes I am confident enough to solve any problem on dp on subsequences !!!!! Thanks a lot sir for this entire series ❤❤❤❤

  • @kiransekhar9510
    @kiransekhar9510 ปีที่แล้ว

    i am able to solve any problem based on subset/subsequence... thanks to you

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

    I can now solve this type question!! Thanks a lot striver

  • @nikhiltidke146
    @nikhiltidke146 2 ปีที่แล้ว +1

    Thanks bhaiya for providing these important series with full effort. You are an inspiration for all of us Tier - 3 college students. I Hope many like me would take benefit of it. Very thankful to you 😊

  • @pertisthsingh
    @pertisthsingh 2 ปีที่แล้ว +1

    Now I can solve any problem on subsequences for sure 🔥.

  • @VivekSharma-eh2tv
    @VivekSharma-eh2tv 2 หลายเดือนก่อน

    hey striver after watching through the lectures iam able to do this problem on my own ...

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

    Understood..Great job!! May the good Lord bless you for all good that u are doing!!

  • @amankrsingh
    @amankrsingh 2 ปีที่แล้ว

    Understood, and now I'm able to solve or try subsequence dp problem