Number of Islands - LeetCode 200 Python

preview_player
Показать описание
Explaining Number of Islands in Python
**lmaoo to clarify what I mean when I keep saying "m by n" @11:27 - I mean to say "m times n if we are given an m by n array" for time and space complexities

Music: Bensound

Lemme know up if y'all have any questions!:)
Рекомендации по теме
Комментарии
Автор

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

chickaberga
Автор

I would like to highlight the uniqueness in your video. Most videos on YouTube 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!

sagittude
Автор

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

priyavardhanpatel
Автор

def got me during my google interview :(

aimie
Автор

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

divyatalesra
Автор

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

khoaanh
Автор

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)

billmono
Автор

How does grid change without a return statement

connornusser-mclemore
Автор

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

anirudhraj
Автор

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

raullopez
Автор

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

augustinthesky
Автор

Thanks so much!! Neat and clear explaination

Drdoggo
Автор

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

aricanadietv
Автор

You explained the recursion really well! Thanks

MIDNightPT
Автор

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<Rw and c>=0 and c<Cw and grid[r][c] != '0':
dfs(grid, Rw, Cw, r, c)





R = len(grid)
C = len(grid[0])
dr = [-1, 1, 0, 0]
dc = [0, 0, 1, -1]


count=0
for i in range(R):
for j in range(C):
if grid[i][j]!='0':
count+=1
dfs(grid, R, C, i, j)


return count

randhivmalhotra
Автор

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!

luca
Автор

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

Nirmaloff
Автор

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

rhapsody
Автор

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

kazeemkz
Автор

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

asgm