Google Coding Question - Divide Chocolate (LeetCode)

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

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

  • @Charles-rn3ke
    @Charles-rn3ke 3 ปีที่แล้ว +3

    The best explanation I have seen! A lot of people just say what tricks should be using here but don't really explain the motivation and how to think of using that trick.

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

    Your description is simple and to the point. Very nice!

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

    Thank you for clearly explaining this!! I have been trying to solve the (very similar) LC 410, and none of the explanations I found were clearly understandable! Will be subscribing

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

    this is the best explanation I have had ever seen. ThankYou. keep it up

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

    Thank You. Subscribed. Keep up the good work!.

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

    Thank you, very clear and well explained. I was struggling to understand the question :( your explanation is on point.

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

    Awesome explanation 👍, will share your channel with my friends.

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

    Man that was easily explained! Great vid

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

    Kudos brother 💓

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

    Nice explanation.

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

    Really good explanation. Just one question - In the canSplit(), should our condition be 'return chunks == k + 1' and NOT 'return chunks >= k +1' - because we need to split it exactly into k + 1 pieces. Isn't it?

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      I think in either case it should work, but I would test it to be 100% sure. I appreciate you watching and commenting!

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

    Please can you explain how the found value is assured to be obtained as a subarray. Is there any proof?

  • @shubhamsharma-sf6lx
    @shubhamsharma-sf6lx 4 ปีที่แล้ว +1

    Waiting for next tricky challenging interesting video :)

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      I have another video scheduled for probably Friday!

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

    in the function you initialised sum to 0 ; shouldn't it be initialised to sweetness[i] ie if(sum > mid){sum = sweetness[i] ;chunks++}
    Assume some conditon
    [1,2,3,4,5] mid = 4
    [1 , 2 , 3 (we cant add 3 here as 1 + 2 + 3 > 4 so we instead add it to second chunk)] so chunk1 = [1,2]
    so for the second chunk we have placed 3 so sum should start from 3 and not 0
    Could you clarify this doubt

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

      ok hear me out maybe what i am thinking is right. btw i have the same doubt but ive observed one thing.
      in question it is mentioned that we should take the least sweet piece. this means our piece's sweetness should be mid then as soon as the first piece sweetness is > mid we do not use the current sweetness[i] in the current piece that is [1,2] which is not following the condition of use having the least sweet piece with sweetness mid=4.
      now if we follow inclusive inequality >= then our condition is met.
      if(sweetness[i]=3)
      [1,2,3] >= 4{
      cnt++; //new sum does not include 3 making sure that previous chunk includes 3 and previous chunk's
      sum=0; //sweet ness is definetly greater than our sweetness that we are aiming to get
      }
      Does this make sense now ?

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

    not a good explanation, you didnt explain the testcases, directly arrived at the algorithm.
    One should make some observations, for example it has a monotonicity where in if we can solve the problem for x then we can solve it for x + 1.
    We have break this problem into a sub problem and then we think how to solve this sub problem, either greedily or use dp or bla bla,
    then arrive to the algo and approach.

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

    Hey Michael which mic you use,i am also thinking to buy a mic,i also run a programming channel

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      I have the Blue Yeti microphone; however, I wouldn't recommend it because I have had lots of problems with it :/

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

    fantastic and comprehensive video, but jfc google, of all the possibilities to describe this problem, why set it in some insane universe where a chocolate bar is asymmetrically sweet?

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      lol i know right. I think that is why this problem has such a low acceptance rate

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

    got a question. should the input array be sorted? Also, the numbers inside the same piece must be consecutive. But I did not find how you handle consecutive numbers

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

      oh , got it. consecutiveness means that they are adjacent in the initial array, not numerically consecutive

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

      Yep, you got it!

    • @geesehoward8838
      @geesehoward8838 4 ปีที่แล้ว

      @@AlgosWithMichael great video!

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      Thanks so much!

  • @theghostwhowalk
    @theghostwhowalk 4 ปีที่แล้ว

    Another gem of explanation! Kudos!
    Request you to do another frequently asked Q from leet # 432 All O one DS...

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

    Is it is MAX(Min) or min(max) problem????

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

    Please cover 417. Pacific Atlantic Water Flow

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

    Thanks for perfect and valuable video! Could you please explain again that why we have to add 1 in mid Variable? I can't understand hundred percent yet..

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

    I have searched entire INTERNET, can you share the DP approach for this problem?

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

      the approach doesn't satisfy the time constraints. there is a question on neetcode which is very similar to this. But the idea is to traverse through recursion and then use dp array. quite complicated and still doesn't pass all the test acses

  • @vivekjaiswal3663
    @vivekjaiswal3663 3 ปีที่แล้ว

    will it work for unsorted array