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!
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!
Did you come up with this solution yourself? Regardless, this is such a remarkable explantation/tutorial. This question got me during my Amazon interview
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
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!:)
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
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!!:))
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!
Ahhh thank you so much Sagar!!! :)))
that's exactly why I subscribed to her
just want to echo what @sagar mentioned. So true. Thank you Deepti!
I watched multiple videos over this problems and you explained it the best. Thank you!!
Ah love hearing this helped thanks sm Raul!!:)
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.
Love hearing this thanks so much!!:)
awesome thank you so much😍, it even helped me to optimize my solution for leetcode 733.
Fantastic delivery, I must admit. I battled with this question for hours. Many thanks.
Thanks so much Kazeem!:))
Thank you so much . This is the solution I'm looking for to understand the depth-first search implementation in this problem.
Aww glad it helped Khoa!! 😊
I really like the way you explain each leetcode problem. Thank you!
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!
Ahhh thanks so much Luca!!
Did you come up with this solution yourself? Regardless, this is such a remarkable explantation/tutorial. This question got me during my Amazon interview
You are just wow! I love the way you explain things. This is what we actually need.
AW thank you Manpreet!!
Excellent explanation! I've stuck with this problem for a whole day. Your video helped me a lot. Thank you!
Love to hear it 😊
The way you explain it is so detailed and informative, very good! Thank you~
Thanks sm Leo!!:))
Finally, I got came to the correct place wow!!!! what a clear explanations love your explanation
Aw thanks so much Nirmal!!!!
This is such an amazing explanation!
Wow!! So helpful!!!! Thanks for the amazing explanation 😍😍😍
I've been stressing about this question for the past week or so... you made it seem so simple!!!!! THANKS A BILLION
ofcc! thank you so much Jon!!!:)
This solution was super intuitive and helpful! Thank you so much!
Aw thx glad to hear it Daniyal!!
Beautiful explanation, please make more videos you are amazing at explaining. Great video :D
Thx sm Andres!:) More coming up!!
def got me during my google interview :(
By far the best explanation!
Thanks so much Manish!!:)
You explained the recursion really well! Thanks
In short... best solutions for similar problem out there
aw ty Anirudh!!:)
Great Explaining. I was literally looking for an explaination in Python and I found your channel.
Great Deepti! I subscribed to the channel!!
Yay!! Thanks sm Samarth!!:)
Thanks so much!! Neat and clear explaination
tysm Saaketh!!:)
beauty with brain
Best answer! Thx!
Thanks so much Vera!!!:)
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)
Such a great explanation, thanks!:)
Thank you so much Monika!!:))
Thank you!
Ofc! Thanks William!:))
How does grid change without a return statement
Excellent explanation, thank you very much!
Thank you so much Matthew!!:)
Thank you. Your explanation was very helpful!
Tysm so glad to hear that Lexi!!
Can you please help me to count islands using Uniform Cost Search. It's my midterm assignment and i have no clue... :(((
awesome
Thanks sm Aniket!!:)
how would one go about counting islands in the special case the island HAS to be a rectangle?
reallllly great explanation thank you
aww thank you so much Sulayman!!:))
amazing dude.. an amazing explanation...
Hehe tyyy Kushagra!:)
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
Thank you so much.. Well explained...
Thank you so much Balaji!!!:))
hi ,
recursiom error : maximum depth exceeded in comparison
how would you convert this dfs to bfs?
great stuff! very confident! Any resources you recommend that helped you gain the mastery of coming up with logic? thanks
Thanks so much Muddasir! Honestly just more practice - the more problems I did the easier it was to come up with logical formulation!:)
Same solution for me exceeded memory
I thought with the double for loop it would make it O(N^2) ?
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!:)
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
@@jeffnguyen91 ofc!! lemme know if you have any other questions!:)
everything is perfect except its not that intuitive
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!!:))