NUMBER OF ISLANDS | PYTHON SOLUTION EXPLAINED | LEETCODE # 200
HTML-код
- Опубликовано: 2 окт 2024
- In this video we are going to be going over how to solve Leetcode problem #200: Number of Islands. This is another quite simple problem that can be solved using a depth first search.
While this problem is not particularly interesting, A LOT of Leetcode problems have a solution that follows this structure so it's definitely important to know how to implement the DFS here.
hey I'm surprised your video has so few views because this solution is honestly the smartest I have seen so far. Most solutions use data structures to store the visited nodes. Your approach of just setting them to 0 is super interesting. Thank you
Thanks for the kind words! Yes I also agree, I should have a lot more views. I'll just be patient and keep making content. My time will hopefully one day come
Brilliant! love your videos, thanks for your efforts :)
Thanks
My first try was DFS, good to know that you are doing the same. Thanks for this solution
simplest solution and explanation !
Instead of solving it using DFS or BFS, you could've used Union Find data structure.
Agreed, union find is also an acceptable answer here. I find DFS simpler to code, more beginner friendly to these sorts of search in 2D grid problems, and the pattern is used in a lot of problems.
@@crackfaang I am following your channel recently. I noticed that you like BFS much more than DFS. My point was you could've explained it using Union Find instead of DFS or BFS. This was a great question to take advantage of that. Anyway, you're doing great work. Keep doing it. Thanks for all the work you're doing.