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
Thanks for this detailed explanation, Loved it! The analogy with Moving Zeroes problem made it a lot easier.
so happy it helped!!
That was a great explanation. Especially referencing move zeros question helps to put things together. Thanks.
Thx Aditya! :)
Thanks for making the interview preparation less painful!
happy to help!
this video is EXTREMELY helpful, really well explained
Tysm! Took a while, glad it was worth it :)
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 :)
Thanks brotha!! I'll make sure to keep the daily content coming and similar to this video :)
As always, very detailed and easy to understand explanation. Thank You.
thank you adya!! :)
God tier explanation, i didn't did the moving zero problem but the explanation was so easy to understand.
Thanks bro!!! Once you do Moving Zeroes it’ll be even easier :)
Great! way to explain. Appreciate your effort.
Pleasure’s all mine! Glad it helped :)
Hands down the best out there. Thank you!
thanks bro
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!
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!
Worth to watch a long video especially for this kind of a problem :)
Great explanation!
tyvm :)
Thanks so much! Nice to listen and easy to understand with your help
Hahah thanks Larisa, super glad you enjoyed it :)
Such a great and crystal clear explanation with fluent English. BTW, you are handsome, Lol. :)
hahaha happy to provide in more ways than one!
Hahah, if something work's don't change that :-P, on a serious note a huge thank you for making these videos!
Hahahah my pleasure. Glad you enjoy them
Really helpful. Thanks, Man!
my pleasure buddy
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!!!
Whoops… good catch 😁
You are amazing
love the clear explanation
Thanks a lot Peifei! Glad you enjoyed it :)
Amazing explanation! Very intutive and elegant indeed
very helpful, thank you!
My pleasure buddy!
great explanation and super clean! thanks :)
Thank you, Elaina!! Super happy you liked it :)
Great explanation
Thank you, this is a great help!
my pleasure :)
Awesome and nice explanation
Great video, thank you for sharing.
Subscribed!
What would the time and space complexity be? I’m thinking O(M+N) because we loop through the rows and cols?
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
You are the man!
Thanks Elbert!!!
Good explanation
Great video, it’s just the logic for the gravity part is throwing me off
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! :)
@@babybear-hq9yd I actually just solved that problem, and it really helped. Thank you
Can you talk about space and time complexity.
the presenter went into details which are required for this kind of problem; Must watch - though watch 2x then you will have it!
#Legend
Request for toonblast leetcode
12:16
Great explanation!