G-9. Flood Fill Algorithm | C++ | Java

preview_player
Показать описание


In case you are thinking to buy courses, please check below:

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

Let's continue the habit of commenting “understood” if you got the entire video.

Do follow me on Instagram: striver_79

takeUforward
Автор

Can't even imagine that the topic that used to send shivers down my spine is now being solved by me, even just after watching the explanation of the problem. Thanks a lot, mate. You are a genius.

anirvangoswami
Автор

After watching the above videos in this playlist, I solved this on my own🥺.
You make every difficult topic an easy one. Thank you so much😊

tejashwinibadi
Автор

Wonderful Explanation I wrote the BFS for it myself

aryanshaw
Автор

For Java people:
int[ ][ ] ans = image; // this won't create the copy of the image array, just that ans is pointing to same as image so we are indirectly changing the original array
to make a copy run nested for loops and copy them individually and store it in ans[ ][ ]

RahulGuptaa
Автор

your graphs series is amazing, after watching all previous videos, i could solve this problem on my own, thank you so much

anikethdeshpande
Автор

Sometimes I just stop listening and start looking at u and admire how beautifully u are explaining this ...thankyou so much

manyagautamrajput
Автор

I just understood the problem from your explanation, found it kind of similar to the no. of islands question, coded it, and bang on I wrote both bfs and dfs code correctly! This series is lit💥

arkajyotinaskar
Автор

solved it without watching the code....because you explained number of islands so beautifully! thank u bhaiya

neelx
Автор

understood!!! har ek video me kuch na kuch naya sikhne ko mil raha h.... not only just soln but writing the code h in efficient way... will surely watch ur dp series after this!!!! waiting for the next lectures of the series
take care!

rohitshrirame
Автор

I was able to solve the problem with BFS and DFS just after you explained the problem. The first 3 minutes were just enough!

abdalla
Автор

striver you are just nailing it, was able to do it without seeing the solution.

becSaurabhKumarSingh
Автор

Explained it like it is a piece of cake. Beauty is how a mammoth topic like Graph look so tiny when u enlighten us.
True Beauty is in Simplicity. Love ur videos. Thank u for sharing ur knowledge and making this a better world.
Tc. Stay safe. Keep growing.

eklavyak
Автор

Understood Bhaiya!!
Bfs approach:
void bfs(int r, int c, vector<vector<int>>& grid, vector<vector<int>> &vis, int color, int prev)
{
int drow[4]={0, 1, 0, -1};
int dcol[4]={1, 0, -1, 0};
queue<pair<int, int>> q;
q.push({r, c});
vis[r][c]=color;
while(!q.empty())
{
int p=q.front().first;
int s=q.front().second;
q.pop();

for(int i=0;i<4;i++)
{
int nr=p+drow[i];
int nc=s+dcol[i];
if(nr>=0 && nr<grid.size() && nc>=0 && nc<grid[0].size() && grid[nr][nc]==prev && vis[nr][nc]!=color)
{
q.push({nr, nc});
vis[nr][nc]=color;
}
}
}

}
vector<vector<int>> image, int sr, int sc, int color) {
int r=image.size();
int c=image[0].size();
//vector<vector<int>> demo=image;
int p=image[sr][sc];
if(p==color)return image;
//dfs(sr, sc, color, p, demo, image);
vector<vector<int>> vis=image;
bfs(sr, sc, image, vis, color, p);
return vis;
// Code here
}

mriduljain
Автор

sir watched your graph series from start and solved this on my own .Thanks❤❤

photon
Автор

U R SUCH AN AMAZING PERSON WITH EXCELLENT TEACHING SIR. GOD BLESS YOU.

preetkatiyar
Автор

Understood! Thank you so much for the great playlist🤩

ishwaripednekar
Автор

Understood! Great explanation as always, thank you very much!!

cinime
Автор

aap jab samjhate ho to kuch bhi samajh jaata bless you

shashankpratapwar-wjxl
Автор

Best graph series EVER 💚 Thank you Striver

BishtiGanika