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

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this video, I'll talk about how to solve the problem Leetcode 956. Tallest Billboard II DP II Reducing DP States II Hashing II 0/1 Knapsack
    Checkout DSA-169 Series: • Aryan DSA-169 Series |...
    Problem Link: leetcode.com/problems/tallest...
    Code & Notes: drive.google.com/file/d/1VauD...
    Let's Connect:
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / aryan_mittal_007
    📱Telegram : t.me/aryan_mittal_group
    🤖 Github: github.com/aryan-0077
    🛍️ Products I use in Videos: (✨ Marked for Mostly requested Products)
    Main Camera (Canon 200D ii): amzn.to/41cfS5h
    Vlog Camera (iphone 13): amzn.to/42aOJRh
    Tripod for Lectures: amzn.to/3HMoloF
    Tripod for Vlogs: amzn.to/44wGL6L
    ✨Mic: amzn.to/41bj8gU
    Shadow Multi Colour Light: amzn.to/41bmIrq
    Main Light: amzn.to/3LF6BNb
    Tripod for Lights: amzn.to/3LFcQAt
    Softbox for Lights: amzn.to/42mHqWE
    ✨My Pen Tablet for Notes: amzn.to/44A61ZJ
    ✨New Tablet for Notes: amzn.to/44BjTDa
    Tablet Stand: amzn.to/3NMFIJR
    Power Bank: amzn.to/421yHsZ
    ✨USB Hub: amzn.to/3p8NGTf
    ✨HardDisk to store Lectures: amzn.to/3HKafEs
    ✨My Laptop: amzn.to/44w12ct
    ✨My Monitor: amzn.to/3LCG6YL
    My UPS: amzn.to/3Lydy2y
    My UPS old: amzn.to/3LXT0C3
    ✨My Mouse: amzn.to/3LYmJdY
    ✨My Keyboard: amzn.to/3NJs4ah
    Resources you can try:
    Learn Coding: • Complete RoadMap for C...
    🎥Channel Playlists
    🎥 Baap Graph Series - by Aryan: • Baap Graph Series - by...
    🎥Dynamic Programming: • Complete Dynamic Progr...
    🎥Bit Manipulation: • Complete BIT MANIPULAT...
    🎥Mathematics for DSA: • Complete Mathematics f...
    🎥Leetcode Top Interview Questions: • FAANG & Leetcode Inter...
    🎥Codeforces Problem B Ladder: • Complete PROBLEM B LAD...
    🎥Codeforces Problem C Ladder: • Codeforces PROBLEM C L...
    🎥Codeforces Problem D Ladder: • Complete PROBLEM D LAD...
    🎥 Top 150 Interview Questions: • Top 150 Interview Ques...
    🎥 Complete Array Problem Playlist: • Complete Array Intuit...
    🎥 Complete Binary Search Problem Playlist: • Complete Binary Search...
    🎥 Complete Stack Playlist: • Complete Stack & Queue...
    🎥 Complete Graph Problem Playlist: • Complete Graph Intuiti...
    🎥 Complete TREE Playlist: • Complete TREE Intuitio...
    🎥 Complete DP Problem Solving: • Complete DP Intuition ...
    🎥 Complete Linked List: • Complete Linked List I...
    🎥 Complete Greedy Problem Playlist: • Complete Greedy Intui...
    🎥 Complete Divide & Conquer Algorithm Playlist: • Complete Divide & Conq...
    🎥 Complete Trie Playlist: • Complete Trie Intuitio...
    🎥 Complete Mathematics & Number Theory Problems: • Complete Mathematics &...
    About Channel:
    We teach about how you can grow in life & educate about programming in Fun & Intuitional way.
    About Me:
    I am Aryan Mittal - a Software Engineer, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    0:00 - Bakwas
    0:35 - Problem Explanation
    3:00 - Intuition Building from Example
    5:41 - How Intuition will work
    8:25 - Summing Up and Getting ready to Code :)
    11:30 - First Intuition Recursion
    16:00 - Complexity
    17:20 - Optimization
    19:50 - Hashing Logic
    22:00 - Optimized Code Explanation
    30:50 - Complexity Analysis
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 58

  • @ARYANMITTAL
    @ARYANMITTAL  Před rokem +4

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

    • @sagarkasana144
      @sagarkasana144 Před rokem

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

  • @vaibhavmehrotra4493
    @vaibhavmehrotra4493 Před rokem +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 Před rokem +11

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

  • @saibhagyaramnidra8006
    @saibhagyaramnidra8006 Před rokem +10

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

  • @PriyanshuSingh-hc3bf
    @PriyanshuSingh-hc3bf Před rokem +10

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

  • @rishabhgupta9846
    @rishabhgupta9846 Před rokem +5

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

  • @summerkoushal679
    @summerkoushal679 Před rokem +1

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

  • @adityapatil7972
    @adityapatil7972 Před rokem +3

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

  • @Saurav_Kumar514
    @Saurav_Kumar514 Před rokem +3

    Wow maja aa gya bro ❤️👌

  • @rakeshydc4139
    @rakeshydc4139 Před rokem +2

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

  • @girishhr9533
    @girishhr9533 Před 10 měsíci

    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

  • @prathamdani9855
    @prathamdani9855 Před rokem +1

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

  • @shieldjarvis7702
    @shieldjarvis7702 Před rokem +1

    Great explanation bro ❤

  • @rishabhkumrawat7575
    @rishabhkumrawat7575 Před rokem

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

  • @sambitbasu6261
    @sambitbasu6261 Před rokem +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.

    • @amankumartiwari1502
      @amankumartiwari1502 Před rokem

      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.

  • @Rushikesh_Khaire
    @Rushikesh_Khaire Před rokem +2

    Dry run karo na bhaiya it will make helpful more.

  • @rtadwq...------...----.

    Nicely explain bhai ❤

  • @Shivanai_h
    @Shivanai_h Před rokem

    nice explanation:)

  • @ayushmishra1207
    @ayushmishra1207 Před měsícem

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

  • @AnkitKumar-sz3by
    @AnkitKumar-sz3by Před rokem

    this was like butter

  • @aashirwadchauhan6634
    @aashirwadchauhan6634 Před rokem +1

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

    • @waltstone5445
      @waltstone5445 Před rokem

      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 Před rokem

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

  • @aryansonwani7061
    @aryansonwani7061 Před rokem

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

  • @healthaction4771
    @healthaction4771 Před rokem +3

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

  • @raghavbhatia5548
    @raghavbhatia5548 Před rokem

    Longest Arithmetic Subsequence???

  • @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

  • @jatinsangwan4342
    @jatinsangwan4342 Před rokem

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

  • @krishnasharma657
    @krishnasharma657 Před rokem +1

    Just use a dictionary in python to avoid the conversion stuff

  • @user-ge8cg8yy6n
    @user-ge8cg8yy6n Před rokem

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

  • @samarpandas9519
    @samarpandas9519 Před rokem

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

    • @rhymes1717
      @rhymes1717 Před rokem

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

  • @visheshpratapsingh3594
    @visheshpratapsingh3594 Před rokem +1

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

    • @souravjoshi2293
      @souravjoshi2293 Před rokem

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

  • @souravjoshi2293
    @souravjoshi2293 Před rokem +2

    You lost me at 27:16

  • @StellasAdi18
    @StellasAdi18 Před rokem +2

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

  • @mayur_madhwani03
    @mayur_madhwani03 Před rokem +1

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

    • @lover_of_u3455
      @lover_of_u3455 Před rokem +1

      @ARYANMITTAL.....pls

    • @souravjoshi2293
      @souravjoshi2293 Před rokem +2

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

    • @mayur_madhwani03
      @mayur_madhwani03 Před rokem

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

  • @tejaspatel2212
    @tejaspatel2212 Před rokem +9

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

    • @ishitakumari3766
      @ishitakumari3766 Před rokem +2

      To mt dekho.

    • @peachpink2831
      @peachpink2831 Před rokem +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 Před rokem +1

      Agree

    • @Yogesh-lv5xv
      @Yogesh-lv5xv Před rokem

      Sala haatho ko jyada fekta hai hawa mein . @ARYANMITTAL

  • @rishabhsonkar4535
    @rishabhsonkar4535 Před rokem +1

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

  • @SWXSTXK
    @SWXSTXK Před rokem +2

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