Fantastic video Alisha mam. I love the way you explain and handle the unprecedented situation like laptop hanging. This qn is quite easy to do but explaining it to others is a difficult task. You nailed it in explanation. I have become your fan :)
One correction - In line 22 you should change row( 2nd paramater) to matrix.size() -1 and column(third parameter) of fnc to i since we are traversing on the last row of grid.
Hi Ma'am, you definitely make the best leetcode solutions!!! Your channel deserves more subscribers!! Your channel will boom one day similar to Nick White
Great explanation !! Watching your explanations, the way you approach the problem matches with my thinking, so I love to watch your explanations. I can relate to the approach unlike other explanations on YT. Kudos to you. Definitely your channel is under valued but surely its gonna boom in the near future.
this is the explanation I was looking for !!. thanks, Beauty with brain!!.
Hey Alisha... great explanation. Thanks for the video. I appreciate your effort.
Amazing walkthrough on DFS through matrix! Thanks!
You have put lot of efforts, thanks for explaining. Helpful.
your videos are gem no matter wat other video give.
thanks for going deep with the depth first search traversal
This is one of the best explanation for this problem.. thank you😊
Fantastic video Alisha mam. I love the way you explain and handle the unprecedented situation like laptop hanging. This qn is quite easy to do but explaining it to others is a difficult task. You nailed it in explanation. I have become your fan :)
Thanks @smartswaggy ...this means a lot!
Thank you for the step-by-step explanation!
This explanation was amazing! Been searching for a long time. Thanks!
One correction - In line 22 you should change row( 2nd paramater) to matrix.size() -1 and column(third parameter) of fnc to i since we are traversing on the last row of grid.
nice explaination di
Hi Ma'am, you definitely make the best leetcode solutions!!! Your channel deserves more subscribers!! Your channel will boom one day similar to Nick White
Can you discuss about the complexity as well??
amazing step by step explaination
Welcome back :)
Best video 💪
wow thanks.... 32:34 struggle is real
great stuff
// SIMPLE C++ USING BFS 99.64% faster
class Solution {
public:
int rows,columns;
vectormovements{{1,0},{-1,0},{0,1},{0,-1}};
bool isValid(int r,int c){
return r>=0 and r=0 and c=heights[r][c] and sea[nr][nc]!=1){
q.push({nr,nc});
}
}
}
}
vector pacificAtlantic(vector& heights) {
rows=heights.size(),columns=heights[0].size();
queueq1,q2;
vectorres,pacific(rows,vector(columns,0)),atlantic(rows,vector(columns,0));
for(int i=0;i
great explanation! thanks a lot.
Great explanation ❤️
Vary well explained
great explanation
great
good explanation, how did you comeup with that idea,how can we develop to think that way.
Thank you!
Keep practicing more variety of problems and that will help to develop thinking
Same questions mentioning RED and BLUE lakes in interviewbit... BFS solution to above approach..
#define RED 1
#define BLUE 0
vector dx = {1, -1, 0, 0};
vector dy = {0, 0, 1, -1};
int m, n;
vector visA, visB;
bool isValid(int i, int j) {
return i >= 0 && j >= 0 && i < m && j < n;
}
void bfs(vector &A, int i, int j, bool lake) {
vector &vis = (lake == BLUE ? visA : visB);
queue q;
q.push({i, j});
int x, y;
while(!q.empty()) {
tie(i, j) = q.front();
q.pop();
if(vis[i][j])
continue;
vis[i][j] = 1;
for(int k = 0; k < 4; k++) {
x = i + dx[k];
y = j + dy[k];
if(isValid(x, y) && A[x][y] >= A[i][j]) {
q.push({x, y});
}
}
}
}
int Solution::solve(vector &A) {
m = A.size(), n = A[0].size();
int ans = 0;
visA = visB = vector (m, vector (n, 0));
for(int j = 0; j < n; j++) {
bfs(A, 0, j, BLUE);
bfs(A, m-1, j, RED);
}
for(int i = 0; i < m; i++) {
bfs(A, i, 0, BLUE);
bfs(A, i, n-1, RED);
}
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
if(visA[i][j] && visB[i][j]) {
ans++;
}
}
}
return ans;
}
Great explanation !! Watching your explanations, the way you approach the problem matches with my thinking, so I love to watch your explanations. I can relate to the approach unlike other explanations on YT. Kudos to you. Definitely your channel is under valued but surely its gonna boom in the near future.
Thank you so much Onkar!
crystal clear
i just don t know how you guys think these things
class Solution {
public:
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
void dfs(int i,int j,int z,vector& heights,vector&reach){
reach[i][j][z]=1;
for(int k=0;k=0 && ni=0 && nj
Thanks Lovelesh
This question took 2 hrs, but i was not able to solve it using brute force
Thanks but really need hindi teacher 😢