Tallest Billboard II DP II Reducing DP States II Hashing II 0/1 Knapsack II Leetcode 956

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 58

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

    Interestingly amazing problem, Thinking Logic is Easy but optimizing is Tricky 🙈, what you guys feel for this problem??
    Checkout DSA-169 Series: ruclips.net/video/5BuKVS-Vnws/видео.html
    Problem Link: leetcode.com/problems/tallest-billboard/description/
    Code & Notes: drive.google.com/file/d/1VauDLaKFieqeA1q2YLP-3hhXME8LYyor/view?usp=sharing

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

      bhaiya i was using unordered_map of string ,it gives me tle then ☹☹

  • @vaibhavmehrotra4493
    @vaibhavmehrotra4493 Год назад +12

    Another way to understand why we added rows[I] to opt2 only--->
    let us consider the function to be returning the max value of s1 (since s1 and s2 are the same)
    op1 tells us the max height of s1 if we do not take the curr rod . Hence the height contribution (on s1) will be 0 and diff will remain same
    op2 tell us the max height of s1 if we add the rod to s1. Hence the height contribution (on s1) will be rods[I] and diff will increase by rods[I]
    op3 tells us the max height of s1 if we add the rod to s2. Hence the height contribution (on s1) will be 0 and the diff will decrease by rods[I]

  • @khushal7363
    @khushal7363 Год назад +11

    bro please make video everyday your explaination is very awesome and help us to learn and remember fast

  • @saibhagyaramnidra8006
    @saibhagyaramnidra8006 Год назад +10

    we want ur explanation.......on previous 2 days problems

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

    Wow maja aa gya bro ❤️👌

  • @PriyanshuSingh-hc3bf
    @PriyanshuSingh-hc3bf Год назад +10

    Please create a video of yesterday's problem.
    It was also a good one.

  • @rishabhgupta9846
    @rishabhgupta9846 Год назад +5

    Bro please also solve yesterday' problem,ab toh tumhara video dekhkar hi clear hota hai

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

    nobody except you can make this problem feel so easy, maybe i will be able to code it by myself now ...

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

    Hey brother just saw your old videos!!, your transformation is insaneeee!!!!!!

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

    You are god brother. I used to skip hard questions but no more. You make them so easy to understand. Thanks a lot!!

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

    bro I am very weak in recursion can you tell me how to improve thinking in recursion

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

    bhaiya i didn't get feel why you ddin't add rods[i] in opt3? btw explanation was awasome as usual🥰

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

    Dry run karo na bhaiya it will make helpful more.

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

    Mate when you explain it all seems so intuitive and easy, but when I go to code it myself, especially thinking out the DP architecture, I can't understand it. And in this problem I still have a little doubt about why we are adding rods[i] only once in the optimised solution.

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

      we are adding once when we add it will increase the difference like it get added in rod1 and now our difference is 0+rod[i] now in next time we don't need to add because if support 2 get added the same number then we should decrease that difference so it will become 0 we are not dealing with rods we are dealing with difference that's why we when adding it we are increasing the difference or else adding in 2nd support we just decreasing the difference and that starting rod so we can get only one rod length that we need to return that's all.

  • @Truysジャ
    @Truysジャ Год назад

    Nicely explain bhai ❤

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

    for me this question seems so easy in beginning, in just 5 minuts I did the recurtion solution, then did dp,but because it is a 3d dp solution it showed memory limit exited

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

    Striver 2.0 bro your explaination way is same as striver i really loved the way you explain

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

    can we use meet in the middle concept to solve this ??

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

    jab 3 states i,s1,s2 leke kar rahe the to usme rod[i] option2 me kyu nahi add kara?

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

      Same confusion.
      I watched this new channel "codestorywithMIK" and got it cleared

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

    Great explanation bro ❤

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

    bhaiya can you make a video on "Minimum Cost to Merge Stones"-- leetcode

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

    Longest Arithmetic Subsequence???

  • @083_h_nitishkumarjha3
    @083_h_nitishkumarjha3 Год назад

    bro one suggestion , speak slower not get too excited , so that you'll be able to put words properly and listening experience also enhances ......btw nice explanation

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

    nice explanation:)

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

    In dp state can we do dp[i][5002-(s1+s2)]

  • @AnkitKumar-sz3by
    @AnkitKumar-sz3by Год назад

    this was like butter

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

    Brute force was easy to get but dp part is very confusing..

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

    sirf opt2 me add kyun kar rahe thik se nahi samajh aaya
    Please reply

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

      @ARYANMITTAL.....pls

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

      Same confusion.
      Same code is present in many places in Leetcode Discuss but none has explained this part well 😞

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

      @@souravjoshi2293 Everyone have just pasted the code
      Noone made an effort to explain how and why of the solution

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

    Thanks for explanation. Not quite clear why rod[i] is not there in option3 :(

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

    Just use a dictionary in python to avoid the conversion stuff

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

    Just a point : Instead of hashing we could've simply used a map.

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

      No I guess, because map will also take the same space complexity.
      Atleast in Java it is throwing a TLE.

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

    Still not clear about adding the rod[i] in opt2 or opt3 ?
    anyone please ?

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

      See for adding the rod in opt 2
      We know diff = S1 + S2 right, if we were to choose option 2 i.e adding length to S1 then diff = S1+rod[i] -s2 = S1-S2 +rod[i]>>>
      Similarly for options 3 we add length to S2 so diff = s1-(S2+rod [i])

    • @083_h_nitishkumarjha3
      @083_h_nitishkumarjha3 Год назад

      @@waltstone5445 bro doubt is why we are not adding the rod[i] in opt3 , like we did in opt2

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

    You lost me at 27:16

  • @tejaspatel2212
    @tejaspatel2212 Год назад +10

    Areh bhai tum video accha banate ho lekin bakwas bahut karte ho! Not everyone has time to watch 30+ min video

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

      To mt dekho.

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

      @@gautamsharma69but Aryan here is providing free help no? if you don't want it then watch somebody else. Who has the time and effort to edit and post daily within hours of the question plus other daily task? Maybe learn to skip to the time stamp of the content you need or look for more sources yourself ¯\_(ツ)_/¯
      There’s plenty of solutions in the designated tab on the question anyways.

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

      Agree

    • @Yogesh-lv5xv
      @Yogesh-lv5xv Год назад

      Sala haatho ko jyada fekta hai hawa mein . @ARYANMITTAL

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

    bhai thda smjhane wali acting km ho to...jyada acha lagega..sasta striver😂

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

    Hindi bol lia kar bhai, teri english smajh nhi aati. Getting my point?