Laughed so hard when you said " Useless neighbors, we need not waste time in talking to such neighbors ". Jokes aside, Thanks for the simple and clear explanation.
int count_Island(vector& grid, int row, int col, int& count) { int m = grid.size(); int n = grid[0].size(); if(row < 0 || col < 0 || row >= m || col >= n || grid[row][col] == 0) { return 0; } // mark grid[i][j] visited as '0' grid[row][col] = 0; // check for 4 directions-> top, bottom, left, right if(count_Island(grid, row-1, col, count)) { // up count++; } if(count_Island(grid, row+1, col, count)) { // down count++; } if(count_Island(grid, row, col-1, count)) { // left count++; } if(count_Island(grid, row, col+1, count)) { // right count++; } return 1; } int maxAreaOfIsland(vector& grid) { int m = grid.size(); int n = grid[0].size(); int ans = INT_MIN; int count = 0; for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) {
hello di please tell ki agar mai top iit me low branch leta hu toh kya mera tech company me ho jayega placement and i am not a too intelligent child i love coding
Yes, you can make it to a good company even if you are not in CS. All you need is to master data structures and algorithms. Like I have done. I was having an earth science branch (at IIT) which has nothing to do with programming yet I'm a software developer at a MnC. Hope it helps. Cheers!!
Laughed so hard when you said " Useless neighbors, we need not waste time in talking to such neighbors ". Jokes aside, Thanks for the simple and clear explanation.
very good explanation thanks!!!
cool and composed, plus nice explanation. not lot of people can present like this. 😀
class Solution {
public:
int areaisland(vector&grid ,int i,int j,int &count ){
if (i>grid.size()||j>grid[0].size()||i
Well explained!! Great job. Keep it up!!
How to exclude water trapped inside an island ?? A slight variation to that problem
int count_Island(vector& grid, int row, int col, int& count) {
int m = grid.size();
int n = grid[0].size();
if(row < 0 || col < 0 || row >= m || col >= n || grid[row][col] == 0) {
return 0;
}
// mark grid[i][j] visited as '0'
grid[row][col] = 0;
// check for 4 directions-> top, bottom, left, right
if(count_Island(grid, row-1, col, count)) { // up
count++;
}
if(count_Island(grid, row+1, col, count)) { // down
count++;
}
if(count_Island(grid, row, col-1, count)) { // left
count++;
}
if(count_Island(grid, row, col+1, count)) { // right
count++;
}
return 1;
}
int maxAreaOfIsland(vector& grid) {
int m = grid.size();
int n = grid[0].size();
int ans = INT_MIN;
int count = 0;
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
if(grid[i][j] == 1) {
count = 1;
count_Island(grid, i, j, count);
}
ans = max(ans, count);
}
}
return ans;
}
Neat explanation 🙌
Super b explanation
understood sister why are you not uploading videos nowadays?
As Usual Nice explanation
but this will not work for input of no '1' in grid
hello di please tell ki agar mai top iit me low branch leta hu toh kya mera tech company me ho jayega placement and i am not a too intelligent child i love coding
Yes, you can make it to a good company even if you are not in CS. All you need is to master data structures and algorithms. Like I have done. I was having an earth science branch (at IIT) which has nothing to do with programming yet I'm a software developer at a MnC. Hope it helps. Cheers!!
@@code_clue can i have ur linkedin profile?
Why u are not moving diagonal ??
doesn't accept
best and easy explanation, thanks