just 2 min watching into approach 3 i coded it without a delay and worked like a charm. made a isSafe function to check if cell is safe or not if its not safe increment count else check if that cell is 0 just 2 check and you are done with question. thanks for your teaching
What is wrong in my code, it fails on 1st testcase only class Solution { public: int m,n; int per; void dfs(int i,int j,vector& grid){ int cnt=0; if(i=m ||j=n||grid[i][j]==0){ per++; return; } if(grid[i][j]==-1){ return; } grid[i][j]=-1; dfs(i-1,j,grid); dfs(i+1,j,grid); dfs(i,j-1,grid); dfs(i,j+1,grid);
} int islandPerimeter(vector& grid) { m=grid.size(); n=grid[0].size(); per=0; for(int i=0;i
Bro yeh 3rd approach kaam nhi kr rha hai pls check: int islandPerimeter(vector& grid) { int r = size(grid); int c = size(grid[0]); for(int i=0; i= 0 && grid[i][j-1] == 0) { ans++; } }
For some reason the comments are not visible in this video. I have raised this to RUclips. Hope they fix this asap.
Thank you for understanding ❤️🙏❤️
I solved this problem my self same as you solved this problem.
king of dsa. you have the power to make a problem look EASY
just 2 min watching into approach 3 i coded it without a delay and worked like a charm. made a isSafe function to check if cell is safe or not if its not safe increment count else check if that cell is 0 just 2 check and you are done with question.
thanks for your teaching
Wonderful explanation, Top notch for beginners.
bas starting ka 5 minutes me hi I understood everything and coded on my own. thanks a lot
Thanks sir i watched 10 minutes of your video and then code it on my own and it got accepted sir.
nice explain
It was like a Medium level problem to me. But after your explanation I coded it myself. Good learning experience for a beginner like me. thanks a lot
sir aap Amazon, Microsoft ya google join kyu ni karte ?
you are next level in coding and your voice and explanation 🔥
There is a reason behind this.
I will soon share this in my Journey Video which I will soon upload on my channel ❤️🙏
@@codestorywithMIK 50K special video
i salute sir what a good explainatoin !! thank uu so much sir
I thought o fth e3rd appraoch first , but just wanted to see how you have explained the bfs solution so I came to watch the video. Loved it!
You make it so easy with your explanation, tysm man
done with 1st approch... thank uuu
Congratulations for 42K Subscribers! ❤
you make things super easy
Bhaiya grid questions ki bhi playlist bna do
more power to u
Congratulations for 42k 🎊 🎉
Good explanation 👏 👍
Also explain leetcode contests solutions and keep up the good work👌
thank you so much brother
Keep growing! ❤
POTD DONE [18.4.24]✅✅
Thanks a lot bhaiya ❤❤ & Congrats for 42k subs 🥳
Congrats mik for 42K 🎉
Hi 😊
I think , this problem is similar to a word search problem in backtracking.
Anybody knowing , in which all questions sir used DIRECTION VECTOR concept? It will be helpful if someone replied....
please make a video on leetcode 1202 question number
@Everyone if question like this is asked in an interview do we need to solve by only dfs or interviewer will ask us to solve by both dfs, bfs?
❤❤
Comment to check if comments are visible!
4th approach.
public int islandPerimeter(int[][]grid){
int m=grid.length,n=grid[0].length,ans=0;
for(int i=0;i
Thanks ❤❤❤❤❤
Aaj blue hai paani paani
Video chapters kaha hai Mazhar sirji.
Added video timelines. Hope that helps
@@codestorywithMIK Thank you sir😇
Hi
Test comment
sie
please aap bhi global variable use krke mt kiya kro, many of us learn from ur solutions
Sure thing. I will take care of this ❤️
What is wrong in my code, it fails on 1st testcase only
class Solution {
public:
int m,n;
int per;
void dfs(int i,int j,vector& grid){
int cnt=0;
if(i=m ||j=n||grid[i][j]==0){
per++;
return;
}
if(grid[i][j]==-1){
return;
}
grid[i][j]=-1;
dfs(i-1,j,grid);
dfs(i+1,j,grid);
dfs(i,j-1,grid);
dfs(i,j+1,grid);
}
int islandPerimeter(vector& grid) {
m=grid.size();
n=grid[0].size();
per=0;
for(int i=0;i
Bro yeh 3rd approach kaam nhi kr rha hai pls check:
int islandPerimeter(vector& grid) {
int r = size(grid);
int c = size(grid[0]);
for(int i=0; i= 0 && grid[i][j-1] == 0)
{
ans++;
}
}
else
continue;
}
}
return ans;
}
};
I think there should be || instead of && in conditions
if(i+1 < r && grid[i+1][j] == 0)