Airbnb Coding Interview Question - Koko Eating Bananas [LeetCode]

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

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

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

    for most of the videos on youtube, I still got confused even I finished watching. But for yours, I already understand it half way through. Great explanation! please make more

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

      I appreciate that, I'm glad you found it useful!

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

      I totally agree with you. This was one of those questions that got me stressing out just by reading it. I watched several videos (including NeatCode) but still did not understand until I got to this video.

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

    Thank you so much for doing these videos! You walk us through every thinking process that is very important for beginners.

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

    Hi Michael, just a little mistake i noticed @ 13:27 since you decrease right at mid -1 which should be 3 instead of 4, then left would be greater than right: no need to go further since left is the answer.
    Thank you very much for your great explanation.

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

    Thank you for the high-quality video! One of my favorite youtubers for leetcode questions. Keep up the amazing work ^^

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

    I cannot possibly understand how someone can be so good at explaining stuff. You are the greatest youtuber of all times in terms of explaining stuff. Your channel is also underrated. You deserve a lot more subscribers and views. Please continue to make solutions to leetcode medium/hard problems.

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

    Thanks for your video. Clear explanations and I like you walking through the codes with examples, which is really helpful!

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

      I'm glad it's helpful, thank you for watching!

  • @Legendary-Akshit
    @Legendary-Akshit 3 ปีที่แล้ว

    Excellent explanation. In the first go itself I could absorb it entirely

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

    meanwhile somebody interviewed Zoomers asking 'Who the first person to land on the sun was', they said "Oo! Niel A-Armstrong!?"

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

    Very nicely explained

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

    Thank you for such an amazing explanation! Please keep uploading such videos :)

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

    Really Thx Michael, That's really helpful. Actually I'm fully confused about this question at the beginning. after this video, I just feel that this question is so easy. Really Thx

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

    Great Explanation. Cleared my doubts of this problem. Thanks.

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

      Glad to hear! Every problem has a pattern

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

    Your channel should be added to the curriculum to prepare for coding interviews

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

    Very well explained, love from Indian🇮🇳

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

    super explanation. Best coding channel for leetcode problems :)

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

    Really helped a lot!! 🍻 keep making such amazing content! God bless!

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

    great video thank you so much! Keep doing the awesome work!

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

    it's really a clear explanation. thanks!

  • @Chandrakumar-ub1uh
    @Chandrakumar-ub1uh 4 ปีที่แล้ว

    great explanation brother u r great solve more famous problems.

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

    Thanks for the explanation!!!
    I'm trying to run this code right now, and its passing all test cases but one. I copied your code line by line. Is this happening for anyone else?

  • @kartik-nain
    @kartik-nain ปีที่แล้ว

    Why are we returning left pointer and not right or mid?

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

    Thanks for the video. Can you please do more videos on similar questions?

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

    Michael, thank you so much for the video. One question, does your solution fail now? It seems they added a new testcase in which your solution doesn't work but it passes all the other testcases

    • @jiecheng.x1306
      @jiecheng.x1306 2 ปีที่แล้ว +1

      Yes. It is beacause the hours variable may exceed the max limit during adding in the canEat method. Just use h to minus and then compare h with 0. And then it works for all test cases.

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

      @@jiecheng.x1306 @Jiecheng .x Thanks! I have a similar issue when h is really big and I fix it with ur method

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

    Can someone explain a little more why we return 'left' at the end?

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

      The reason why we return `left` at the end is because if left and right become equal, that means the answer MUST be `left` since that is the last possible choice.

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

    crystal clear ..

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

    Can you reiterate why right=max(nums)?

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

      The whole point of a binary search is to find our answer in the range of [left, right] in an efficient way. Restricting our range to the max of the number is a way to optimize the range we have to look through. The array contains piles of bananas and we are trying to find the min K, thus the max in our array would be the most that koko could eat in a day.

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

    canEatInTime is the hardest part for me

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

      Yea, it can be a bit confusing, but that part is how many binary search problems can be solved.

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

    Great explanation.... You could have used math.ceil

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

    Can We return mid instead of left?

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

      No, it has to be left because mid is inside of our while loop and doesn't have scope outside of it.

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

      @@AlgosWithMichael how do we come up with the logic to return the left pointer always ?
      At the end of while loop : left = right = mid
      If canEatInTime is true for this mid , then break and return left
      if its false , we increase left to the next possible value left = mid + 1 ( since left == mid , its basically left++ ) and return the left + 1 value . How is it guaranteed that the next left+1 will always give the solution ?