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.

Комментарии • 9

  • @DjahanLatran
    @DjahanLatran 8 месяцев назад +1

    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

    • @crackfaang
      @crackfaang  8 месяцев назад +4

      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

  • @shraddhabarke1750
    @shraddhabarke1750 6 месяцев назад

    Brilliant! love your videos, thanks for your efforts :)

  • @subee128
    @subee128 8 месяцев назад +1

    Thanks

  • @HarishRaoS
    @HarishRaoS Год назад

    My first try was DFS, good to know that you are doing the same. Thanks for this solution

  • @SENSEIFILES
    @SENSEIFILES Год назад

    simplest solution and explanation !

  • @SheikhSadiruddin1
    @SheikhSadiruddin1 2 года назад

    Instead of solving it using DFS or BFS, you could've used Union Find data structure.

    • @crackfaang
      @crackfaang  2 года назад +1

      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.

    • @SheikhSadiruddin1
      @SheikhSadiruddin1 2 года назад +1

      @@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.