Hey thanks for the solution, but is the worst case really n^2? Seems more like it would be n^4. Imagine a large grid of all 1s. You'll immediately enter the first tile and do a dfs across all tiles (n^2). But then when you exit the function you're still needing to loop across every time even though you've already covered it. Am I missing something here?
By far the most clear explanation I've seen thank you!!
Hey thanks for the solution, but is the worst case really n^2? Seems more like it would be n^4. Imagine a large grid of all 1s. You'll immediately enter the first tile and do a dfs across all tiles (n^2). But then when you exit the function you're still needing to loop across every time even though you've already covered it.
Am I missing something here?
Nice explanation buddy,you have explained very well 👍👍👍
after few similar 2D traversing case, I've finally have a better understanding of the dfs algorithm and this video helped a lot. thanks
awesome, thanks buddy
excellent explaination, you deserve more followers, I have my google interview 2 days later, wish me luck fam
very nice explanation!
Thanks!