CANDY CRUSH (Leetcode) - Code & Whiteboard

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • A problem that's been very popular with Bloomberg and Facebook, Candy Crush is based on the algorithm in the very popular mobile application game. Here we do a walkthrough of the solution of how to crush the candies until stable-state is achieved.
    Let me know if you have any questions about the solution, or would like help with any other part of your studies + preparation!
    leetcode.com/p...
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------
    Let's connect on LinkedIn!
    / aleksmitrovic
    Follow me on Medium!
    / mitrovic.aleksandar
    Questions or suggestions for new videos? Email me!
    babybear4812@gmail.com

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

  • @nayankhanna2367
    @nayankhanna2367 3 ปีที่แล้ว +8

    Thanks for this detailed explanation, Loved it! The analogy with Moving Zeroes problem made it a lot easier.

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

    That was a great explanation. Especially referencing move zeros question helps to put things together. Thanks.

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

    Thanks for making the interview preparation less painful!

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

    this video is EXTREMELY helpful, really well explained

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว

      Tysm! Took a while, glad it was worth it :)

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

    It was a great explanation, good work man! I think the longer video was actually necessary to explain the entire solution and it was very clear :)

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว

      Thanks brotha!! I'll make sure to keep the daily content coming and similar to this video :)

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

    As always, very detailed and easy to understand explanation. Thank You.

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

    God tier explanation, i didn't did the moving zero problem but the explanation was so easy to understand.

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว +1

      Thanks bro!!! Once you do Moving Zeroes it’ll be even easier :)

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

    Great! way to explain. Appreciate your effort.

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว

      Pleasure’s all mine! Glad it helped :)

  • @CongNguyen-og3iz
    @CongNguyen-og3iz ปีที่แล้ว

    Hands down the best out there. Thank you!

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

    If we do everything in a while loop instead of using a recursive stack, would that make a difference? (talking in terms of space-complexity) - however, loved the explanation!

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว +1

      Hey there, great point! I didn't even notice that the first time around. I've just tried to refactor the code, and it indeed can be done with a couple of small modifications :) Thanks for the shout!

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

    Worth to watch a long video especially for this kind of a problem :)

  • @mr.anonymous6098
    @mr.anonymous6098 2 ปีที่แล้ว

    Great explanation!

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

    Thanks so much! Nice to listen and easy to understand with your help

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว

      Hahah thanks Larisa, super glad you enjoyed it :)

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

    Such a great and crystal clear explanation with fluent English. BTW, you are handsome, Lol. :)

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว +2

      hahaha happy to provide in more ways than one!

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

    Hahah, if something work's don't change that :-P, on a serious note a huge thank you for making these videos!

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว

      Hahahah my pleasure. Glad you enjoy them

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

    Really helpful. Thanks, Man!

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

    Hi @babybear4812! Not a major correction but just a minor one: in case of error checking it will be "return board" not just "board". Thanks for the amazing video! Cheers!!!

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

    You are amazing

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

    love the clear explanation

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว

      Thanks a lot Peifei! Glad you enjoyed it :)

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

    Amazing explanation! Very intutive and elegant indeed

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

    very helpful, thank you!

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

    great explanation and super clean! thanks :)

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว

      Thank you, Elaina!! Super happy you liked it :)

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

    Great explanation

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

    Thank you, this is a great help!

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

    Awesome and nice explanation

  • @Nara-ec1jc
    @Nara-ec1jc 3 ปีที่แล้ว

    Great video, thank you for sharing.

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

    Subscribed!

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

    What would the time and space complexity be? I’m thinking O(M+N) because we loop through the rows and cols?

    • @babybear-hq9yd
      @babybear-hq9yd  2 ปีที่แล้ว +2

      I don’t remember, but since we’re going through the whole grid my guess would be O(M*N). May be a bit more to it given how we’re crushing the candy and dropping them down but still stand by my initial thought

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

    You are the man!

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

    Good explanation

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

    Great video, it’s just the logic for the gravity part is throwing me off

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว +1

      The gravity part is actually just a rendition of the "Move Zeroes" problem on Leetcode, Problem 283. In "Move Zeroes" we need to take any zeroes and move them to the end of the array, while maintaining the order of the rest of the elements as they were.
      Except in this case we need to think about that problem vertically instead of horizontally. We're moving"the negative numbers to the "end", or essentially the top of the 2D array.
      I don't think I have a video up on it because it's been reviewed a lot already. However, the solution is available on Leetcode. I would suggest the solution they covered in Approach 2. It's in C++, but the logic is identical to what I did here. Hope this helps! :)

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

      @@babybear-hq9yd I actually just solved that problem, and it really helped. Thank you

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

    Can you talk about space and time complexity.

  • @RG-yj4cb
    @RG-yj4cb 3 ปีที่แล้ว

    the presenter went into details which are required for this kind of problem; Must watch - though watch 2x then you will have it!

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

    #Legend

  • @user-dc8kp2ei4h
    @user-dc8kp2ei4h 6 หลายเดือนก่อน

    Request for toonblast leetcode

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

    12:16

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

    Great explanation!