Filling Bookcase Shelves - Leetcode 1105 - Python

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

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

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

    I love how you keep going back to your 150, honestly I also recommend the same to everyone that asks me.
    Kudos! Nice explanation!

  • @vishaalkumaranandan2894
    @vishaalkumaranandan2894 3 หลายเดือนก่อน +20

    The way you erased the entire question was really funny

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

    I find the combining part really confusing using a bottom-up approach. Solving it in recursive is way more easy to understand for me!

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

    I have to watch editorial literally every time it is a dp problem. At this point, I am thinking may be dp is not for me. I get stuck in finding the way to get to the base case and through which viewpoint.

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

    How do we visualize looping from the last book in the second solution? Are we starting with the last book in the first shelf and then slowly building off that? Or are we imaging the last book being on some arbitrary top shelf

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

    I could think of two parameter based recursive function, but I don’t think I could have thought of considering the shelf number as parameter. There is no logical flow from first to second, it is just practice I am guessing

    • @shivansh-gup
      @shivansh-gup 3 หลายเดือนก่อน

      this exactly. also could you show your 2 variable solution ?

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

    Identifying which pattern to use... Still the hardest part that makes me fail
    Thanks for the clear explanation Neet!

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

    2nd! Thanks! My mind was freeze until watching your video!

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

    hey man! How does one become as eloquent as you? Imagine being this eloquent in an interview? Damn!

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

      Don't get discouraged, he's a good programmer but his video solution is very prepared and organized.

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

    Thought binary search would work here. Worked out a few examples and figured, partitions using DP is more like it.

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

    Amazing time complexity explanation

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

    How can you get the intuition for line 17
    res = min(res, maxHeight+helper(j+1) ??

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

    When cur_width < width, we break out of the for loop. But what if the subsequent book eg. books[j+1] can fit into the current shelf? Do we not have to consider that?

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

      no because we gotta place the books in order

  • @MP-ny3ep
    @MP-ny3ep 3 หลายเดือนก่อน

    Great explanation as always. Thank you

  • @Cheng-K
    @Cheng-K 3 หลายเดือนก่อน

    Great explanation !

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

    I solved with multiple parameters but then when I tried to cache it I wasn't able to do it. Pretty interesting that I can try the path to remove parameters somehow.

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

    Great explanation!!

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

    The recurrence relation is intuitive - I got it down pat except when I tried to follow your solution, I had to rewind and watch it multiple times.
    Nothing on you, it's just one of those problems where you get it but when you're translating it to code you're stuck.

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

    He’s fast with it, my initial solution was O(n^2logn) 😢
    I misread the question as that we could reuse the previous bucket but we just go in orders so I had to track all the previous buckets

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

    Before I forget, i don't know if the 2nd solution is this or what,
    but i thought if we start from last, and like use greedy, then it will work...

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

    Wondering what if the Books can be put on shelf NOT in order and find MIN height?

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

    Intuition of Partition dp

  • @IK-xk7ex
    @IK-xk7ex 3 หลายเดือนก่อน

    The time then Padawan defeated his Master. :)

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

    i really hate when they give us these type of problems like where is the critical thinking when the brute force is the most optimal solution

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

      DP is not exactly brute force. Though ofc it's easy to recognize it after seeing it a bunch of times and doesn't require much thought if you understand it. But that's basically all Leetcode Easys and Mediums. On the other hand, the majority of average devs probably wouldn't realize it, if they even know DP at all.

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

      brute force is trying out all the possible permutations of the books and picking the least height

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

    My foolish self thought this could be solved using greedy algorithm running from the front and the back and then get the min of the two totalHeights 😅😅😅

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

      Same but slightly different, I thought about using a max heap to find out the biggest two heights within a gap of shelf width then determine if the max in current shelf is below the 2nd biggest, if it is then we can't put the largest book in the current shelf

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

    17:00 ηρεμησε μπρο

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

    I don't understand why people say the question isn't clear everytime
    I think the question is clear enough and doesn't miss anything

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

      It doesn't say anything about reusing the shelf empty slots. I had to literally make up and run two test cases just to confirm this.

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

    navdeep paaji please spare us noobs

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

    why can't we put "3" at the first row and shift "4 5 6 7" one step to the above row, so that the answer for the given example would be 5 instead of 6.

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

      The shelf is only 4 wide. Books 1-3 togheter are 5 wide.

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

    the explanation couldn't have been more confusing tho

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

      Anything that you thought could be more clear?
      The whole idea is for every recursive call helper(i) we are starting at a new shelf and start at books[i]. Everything else can be derived from there. I made sure to mention this multiple times throughout the video.

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

      @@NeetCodeIO Hey thanks for this comment,Initially we are placing a book in new shelf and then combining them from the first shelf to last shelf?

  • @prajwals8203
    @prajwals8203 22 วันที่ผ่านมา

    again this month? why??

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

    Day 0 of asking dry run of code by diagram.

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

      Isn't that something you can do yourself? I promise you will understand it better if you do. I didn't get good by watching videos.

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

    1st

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

      dam that was fast

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

      @@NeetCodeIO lol sry for creeping

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

    Man I really try to watch these, but the amount of bloating just to make the videos longer is maddening..

    • @NeetCodeIO
      @NeetCodeIO  3 หลายเดือนก่อน +10

      There are time stamps if you wanna skip to specific parts. Is there anything specific you thought was redundant?
      Generally dynamic programming videos are always longer since they have multiple solutions.