Number of Islands - LeetCode 200 Python

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 78

  • @sagittude123
    @sagittude123 Před 3 lety +15

    I would like to highlight the uniqueness in your video. Most videos on CZcams explaining Leetcode problems, either go over the solution on whiteboard, and then the coding and then they are done
    No explanation of how the algorithm runs using an example (if it runs), which is so important in interviews.
    You have done such a great job in going through the high level algorithm , the code and then how the code would run. That just set you apart! Thanks a lot and well done!

  • @raullopez3029
    @raullopez3029 Před 2 lety +1

    I watched multiple videos over this problems and you explained it the best. Thank you!!

    • @DEEPTITALESRA
      @DEEPTITALESRA  Před 2 lety

      Ah love hearing this helped thanks sm Raul!!:)

  • @MrRenaissance17
    @MrRenaissance17 Před 2 lety +1

    I love how you broke this down I was confused at first but after watching it again I understood what you were doing. Great Video.

  • @priyavardhanpatel6155
    @priyavardhanpatel6155 Před rokem +2

    awesome thank you so much😍, it even helped me to optimize my solution for leetcode 733.

  • @kazeemkz
    @kazeemkz Před 2 lety +1

    Fantastic delivery, I must admit. I battled with this question for hours. Many thanks.

  • @khoaanh7375
    @khoaanh7375 Před 2 lety +1

    Thank you so much . This is the solution I'm looking for to understand the depth-first search implementation in this problem.

  • @aricanadietv3795
    @aricanadietv3795 Před 2 lety +1

    I really like the way you explain each leetcode problem. Thank you!

  • @luca8834
    @luca8834 Před 3 lety +1

    I've never commented on anyone's video but your video really helped me understand the question well. Great work and I hope to see more videos from you!

  • @chickaberga2
    @chickaberga2 Před 3 lety +16

    Did you come up with this solution yourself? Regardless, this is such a remarkable explantation/tutorial. This question got me during my Amazon interview

  • @manpreetkour2345
    @manpreetkour2345 Před 2 lety +1

    You are just wow! I love the way you explain things. This is what we actually need.

  • @rhapsody9442
    @rhapsody9442 Před 2 lety +1

    Excellent explanation! I've stuck with this problem for a whole day. Your video helped me a lot. Thank you!

  • @leomiao5959
    @leomiao5959 Před 2 lety +1

    The way you explain it is so detailed and informative, very good! Thank you~

  • @NirmalLogs
    @NirmalLogs Před 2 lety +1

    Finally, I got came to the correct place wow!!!! what a clear explanations love your explanation

  • @scoobyy3112
    @scoobyy3112 Před 7 měsíci +1

    This is such an amazing explanation!

  • @divyatalesra4767
    @divyatalesra4767 Před 3 lety +4

    Wow!! So helpful!!!! Thanks for the amazing explanation 😍😍😍

  • @jonparicien316
    @jonparicien316 Před 3 lety

    I've been stressing about this question for the past week or so... you made it seem so simple!!!!! THANKS A BILLION

  • @daniyalkabir6527
    @daniyalkabir6527 Před 2 lety +1

    This solution was super intuitive and helpful! Thank you so much!

  • @asgm1382
    @asgm1382 Před 2 lety +1

    Beautiful explanation, please make more videos you are amazing at explaining. Great video :D

  • @aimie2837
    @aimie2837 Před 2 lety +2

    def got me during my google interview :(

  • @manishpatil1949
    @manishpatil1949 Před 2 lety +1

    By far the best explanation!

  • @MIDNightPT4
    @MIDNightPT4 Před 2 lety +1

    You explained the recursion really well! Thanks

  • @anirudhraj3984
    @anirudhraj3984 Před 2 lety +1

    In short... best solutions for similar problem out there

  • @samCoder
    @samCoder Před 3 lety

    Great Explaining. I was literally looking for an explaination in Python and I found your channel.
    Great Deepti! I subscribed to the channel!!

  • @Drdoggo24
    @Drdoggo24 Před 3 lety +3

    Thanks so much!! Neat and clear explaination

  • @mdmasiud542
    @mdmasiud542 Před 2 lety +1

    beauty with brain

  • @emmawu8137
    @emmawu8137 Před 2 lety +1

    Best answer! Thx!

  • @billmono9466
    @billmono9466 Před 3 lety +1

    Why the time complexity is only O(m*n)? Inside the nested loop, you call a function that iterates in the list, which should be O(m*n*dimension list)

  • @monikajavadi1274
    @monikajavadi1274 Před 3 lety +1

    Such a great explanation, thanks!:)

  • @williamleratakis7667
    @williamleratakis7667 Před 2 lety +1

    Thank you!

  • @connornusser-mclemore631
    @connornusser-mclemore631 Před 3 lety +1

    How does grid change without a return statement

  • @04mfjoyce
    @04mfjoyce Před 3 lety

    Excellent explanation, thank you very much!

  • @Lexi-by8zd
    @Lexi-by8zd Před 3 lety

    Thank you. Your explanation was very helpful!

  • @augustinthesky
    @augustinthesky Před 2 lety

    Can you please help me to count islands using Uniform Cost Search. It's my midterm assignment and i have no clue... :(((

  • @aniketninawe1228
    @aniketninawe1228 Před 3 lety +1

    awesome

  • @axscs1178
    @axscs1178 Před 2 lety

    how would one go about counting islands in the special case the island HAS to be a rectangle?

  • @sulaymanali8080
    @sulaymanali8080 Před 3 lety

    reallllly great explanation thank you

  • @kushagrasen1848
    @kushagrasen1848 Před 3 lety

    amazing dude.. an amazing explanation...

  • @randhivmalhotra8268
    @randhivmalhotra8268 Před 2 lety

    What is my mistake?
    def numIslands(self, grid):
    """
    :type grid: List[List[str]]
    :rtype: int
    """
    if grid ==None or len(grid)==0 :
    return -1
    def dfs(grid,Rw,Cw,r,c):
    grid[r][c] = '0'
    for i in range(4):
    r+=dr[i]
    c+=dc[i]
    if r>=0 and r=0 and c

  • @balajiravindran2228
    @balajiravindran2228 Před 3 lety

    Thank you so much.. Well explained...

  • @shivaexerciseshealthyrecip2723

    hi ,
    recursiom error : maximum depth exceeded in comparison

  • @sashimi3637
    @sashimi3637 Před 3 lety

    how would you convert this dfs to bfs?

  • @muddasirkhan805
    @muddasirkhan805 Před 3 lety

    great stuff! very confident! Any resources you recommend that helped you gain the mastery of coming up with logic? thanks

    • @DEEPTITALESRA
      @DEEPTITALESRA  Před 2 lety +2

      Thanks so much Muddasir! Honestly just more practice - the more problems I did the easier it was to come up with logical formulation!:)

  • @sahilmakwane5115
    @sahilmakwane5115 Před 2 lety

    Same solution for me exceeded memory

  • @jeffnguyen91
    @jeffnguyen91 Před 3 lety

    I thought with the double for loop it would make it O(N^2) ?

    • @DEEPTITALESRA
      @DEEPTITALESRA  Před 3 lety +1

      Hey Jeff! By the double for loop, do you mean the one in the function as well as the helper function? 
If so I can def explain more in-depth about that! :)
      Essentially for time complexity, we have an m x n array where m is the number of rows and n is the number of columns. From this we know we have a total of m(n) cells and visit each one. Because of this, we can say that our time complexity is of order O(mn). Of course, it is possible that we have a group of islands that we visit and mark as seen, and later on, could also traverse over the same cell we had already marked. This makes it so that it is possible we visit one cell twice (first as an island to mark as "0", and then over the original traversal where we check for any "1" marked cells). The worst case for this - suppose that the entire grid is just 1’s - we mark the entire grid and still iterate over every single 0. This means we’ve gone over all of the m(n) cells twice. This however, is 2*m*n and still of the order O(mn)!
      Let me know if this helps or if your question was about something else - always happy to explain further!:)

    • @jeffnguyen91
      @jeffnguyen91 Před 3 lety

      Ahh I see now. I was thinking whenver there is a double for loop it would be a o(n^2) time complexity for example if you were to do a brute force solution for 2 sum. But in this case its not doing that. Thanks for the clarification !!@@DEEPTITALESRA

    • @DEEPTITALESRA
      @DEEPTITALESRA  Před 3 lety +1

      @@jeffnguyen91 ofc!! lemme know if you have any other questions!:)

  • @aaditya_87
    @aaditya_87 Před rokem

    everything is perfect except its not that intuitive

    • @DEEPTITALESRA
      @DEEPTITALESRA  Před rokem

      yea def at first if you aren't used to thinking this way/solving these problems it can def seem out of the box. But once you start doing more of these problems, it'll become not only intuitive, but super easy Aditya!!:))