flood fill leetcode | flood fill leetcode python | flood fill python solution | Interview question

preview_player
Показать описание
Please like the video, this really motivates us to make more such videos and helps us to grow. thecodingworld is a community which is formed to help fellow student and professionals looking to crack the “coding interviews”.

We love solving and sharing problems which are frequently asked in technical interviews and voted by community at various websites.

✅ For more and upcoming updates join our community

#leetcode #python
Рекомендации по теме
Комментарии
Автор

hey thankyou...it's very helpful 👍

snehill
Автор

I used the similar approach that was used in Number Of Islands problem.
But I missed the condition were current color == newColor; that caused recursion depth to exceed.
Thanks for the video.
This is my solution
Code:
def dfs(image, i, j, color, newColor):
if i < 0 or i >= len(image) or j < 0 or j >= len(image[0]) or image[i][j] != color or image[i][j] == newColor:
return

image[i][j] = newColor
dfs(image, i+1, j, color, newColor)
dfs(image, i, j+1, color, newColor)
dfs(image, i-1, j, color, newColor)
dfs(image, i, j-1, color, newColor)


dfs(image, sr, sc, image[sr][sc], newColor)
return image

crimsoncad
Автор

Thanks. Whats the time complexity? Space complexity O(1)?

Swole_coder
Автор

What do you use to record and draw? Is that an ipad?

pancernymisiek
visit shbcf.ru