Тёмный

LeetCode 733. Flood Fill (Algorithm Explained) 

Nick White
Подписаться 386 тыс.
Просмотров 58 тыс.
50% 1

The Best Place To Learn Anything Coding Related - bit.ly/3MFZLIZ
Join my free exclusive community built to empower programmers! - www.skool.com/...
Preparing For Your Coding Interviews? Use These Resources
--------------------
(My Course) Data Structures & Algorithms for Coding Interviews - thedailybyte.d...
AlgoCademy - algocademy.com...
Daily Coding Interview Questions - bit.ly/3xw1Sqz
10% Off Of The Best Web Hosting! - hostinger.com/...
Follow Me on X/Twitter - x.com/nickwhit...
Follow My Instagram - / nickwwhite
Other Social Media
----------------------------------------------
Discord - / discord
Twitch - / nickwhitettv
TikTok - / nickwhitetiktok
LinkedIn - / nicholas-w-white
Show Support
------------------------------------------------------------------------------
Patreon - / nick_white
PayPal - paypal.me/nick....
Become A Member - / @nickwhite
#coding #programming #softwareengineering

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@biswamohandwari6460
@biswamohandwari6460 4 года назад
You have the ultimate power to make us understand complex problems very easily that's what makes you powerful. Your the best...
@TheBsoncarty
@TheBsoncarty 2 года назад
Idk if you read these comments anymore, but I want to say thanks dude. These videos that you've made have been vital to my ability to understand how to approach LeetCode questions.
@ahmadalk2540
@ahmadalk2540 3 года назад
this line saved my day thanks! I was going with stackOverFlow exception without it. if ( image[sr][sc] == newColor ) return image;
@vyshnavramesh9305
@vyshnavramesh9305 4 года назад
1:21 number of islands, flood fill, rotten oranges.....etc basically bfs n dfs algos
@ruibinzhang
@ruibinzhang Год назад
The most blessed thing is that I am stuck with a question, but Nick has already solved it and made a video.
@adityap613
@adityap613 Год назад
You were right, this is almost identical to number of islands. Once I got this I figured that one out pretty quickly.
@kishoureb6833
@kishoureb6833 3 года назад
Thanks a lot for the clear explanation. Just keep doing this awesome work. It really means a lot to me.
@tushargupta2356
@tushargupta2356 4 года назад
your mistake was a good thing to learn from
@thommy270
@thommy270 2 года назад
Keep doing that awesome work man! Got it instantly, your explanations are very clear.
@stith_pragya
@stith_pragya 10 месяцев назад
Thank You So for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@smellthel
@smellthel 3 года назад
So there are 732 other episodes of this series?
@theonly1me
@theonly1me 2 года назад
it's kinda funny how Nick is always High :D
@jacksingermusic
@jacksingermusic 2 года назад
What is the time and space complexity? I'm guessing time = O(n) and space = O(1). Is that right?
@prathyushakadali3330
@prathyushakadali3330 4 месяца назад
Thanks so much for sharing this, but doesn't this cause repetition? for eg: void fill method is called for sr=1, sc=1, more than it is required.
@prathyushakadali3330
@prathyushakadali3330 4 месяца назад
image[sr][sc]==newColor, condition has to be added under if condition of void fill?
@ruibinzhang
@ruibinzhang Год назад
The first line is essential; otherwise, the recursion function call will go into an infinite loop.
@sanskargupta7800
@sanskargupta7800 3 года назад
hello Sir i am getting stuck at the below test case [[0,0,0],[1,0,0]] 1 0 2
@zn4798
@zn4798 4 года назад
just very curious why you need to write another function, is it possible that return it in the same function? I mean use the recursive for the function floodfill
@sfitz219
@sfitz219 3 года назад
You could put the old color in a variable at the beginning of the function, and put each of the recursive calls in an if statement, which checks if that index would be out of bounds, and if that pixel is the same color. That was what I tried first, it worked on small images on my computer, it only passed the first 16 test cases on leetcode website before getting a stack overflow on the 17th. When I added a check at the beginning that returns the unmodified image if the oldColor == newColor, it started working. I guess one of the test cases is a huge image where the pixel they try starting the flood fill at is already the color they're filling it with.
@ZEE-fs6hv
@ZEE-fs6hv 5 лет назад
just 850 problems away to complete all leet code problems😀😀
@vishalcelestine8654
@vishalcelestine8654 4 года назад
R u doing ur UG now ?
@mashak3765
@mashak3765 3 года назад
1692 more to go for me !
@harinijeyaraman8789
@harinijeyaraman8789 4 года назад
Your videos are really helpful man ! Thanks a ton
@amrholo4445
@amrholo4445 2 года назад
Thanks so much Also the last mistake i didn't know about it, thanks man
@jaideeph6985
@jaideeph6985 Год назад
Will this work if the starting point is [0][0] ??
@richa6695
@richa6695 4 года назад
we optimize this by not visiting nodes again which are already visited right?
@dileshsolanki2383
@dileshsolanki2383 4 года назад
@Richa won't that part get handled in the condition img[sr][sc] !=color ?
@sanatgawade8045
@sanatgawade8045 2 года назад
Can anyone explain why sc >= image[0].length and not sc >= image.length ?
@jesusjurado222
@jesusjurado222 2 года назад
The image will not always be square, so sr is limited to the length of the encompassing array, and sc will be limited to the length the nested array.
@RagingAcid
@RagingAcid Год назад
Thanks purge
@janneskleinau6332
@janneskleinau6332 Год назад
this is so cool!
@expansivegymnast1020
@expansivegymnast1020 2 года назад
Good explanation!
@eliastouil7686
@eliastouil7686 4 месяца назад
Thanks
@mohammedharoon1167
@mohammedharoon1167 5 месяцев назад
you are just awesome
@DaBestn00b
@DaBestn00b 4 года назад
how do i get 100% faster than everyone else
@MrRaminfar
@MrRaminfar 2 года назад
If the new color is the same as the old color, wouldn't that make an infinite recursion
@alexwilkinson3460
@alexwilkinson3460 2 года назад
No, that's caught by line 3. It never even gets to the recursive function. "if (image[sr][sc] == newColor) return image;"
@rhinoara7119
@rhinoara7119 2 года назад
When Asians watching your videos, you know how good you are
@AnandBaburajan
@AnandBaburajan 3 года назад
4:21 boi
@drewanderson5867
@drewanderson5867 4 года назад
Hey the discord link is invalid, can someone send me the link, or comment it
@MsFerid567
@MsFerid567 2 года назад
GOAT
@dannyhd8301
@dannyhd8301 2 года назад
👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏
@davidrowlands8548
@davidrowlands8548 2 года назад
Decent!
@radwaneberredai6622
@radwaneberredai6622 5 лет назад
python problém
Далее
G-9. Flood Fill Algorithm | C++ | Java
20:34
Просмотров 247 тыс.
Leetcode - Flood Fill (Python)
7:01
Просмотров 8 тыс.
РЫБКА С ПИВОМ
00:39
Просмотров 521 тыс.
LeetCode 146. LRU Cache (Algorithm Explained)
18:00
Просмотров 118 тыс.
LeetCode 56. Merge Intervals (Algorithm Explained)
12:57
Self Taught Programmers... Listen Up.
11:21
Просмотров 1 млн
The Fastest Maze-Solving Competition On Earth
25:22
Просмотров 20 млн
I Got Rejected (again)
9:43
Просмотров 205 тыс.
How does flood fill work?
8:10
Просмотров 27 тыс.
Coding Was Hard Until I Learned THESE 5 Things!
8:02
Dynamic Programming / Flood Fill Algorithm
5:45
Просмотров 95 тыс.
Flood Fill | Leetcode #733
10:33
Просмотров 54 тыс.