great explanation sirr🔥🔥 Aryan bhai help me for 21 days to start again to come back on DSA after 6 months of gap do keep consistently posting video I will also continue with you in the same journey
class Solution { public: void solve1(vector& grid, vector& vis, int i, int j) { int m = grid.size(), n = grid[0].size(); for (int col = j + 1; col < n; col++) { if (grid[i][col] != 0) break; vis[i][col] = 1; } } void solve2(vector& grid, vector& vis, int i, int j) { int m = grid.size(), n = grid[0].size(); for (int col = j - 1; col >= 0; col--) { if (grid[i][col] != 0) break; vis[i][col] = 1; } } void solve3(vector& grid, vector& vis, int i, int j) { int m = grid.size(), n = grid[0].size(); for (int row = i + 1; row < m; row++) { if (grid[row][j] != 0) break; vis[row][j] = 1; } } void solve4(vector& grid, vector& vis, int i, int j) { int m = grid.size(), n = grid[0].size(); for (int row = i - 1; row >= 0; row--) { if (grid[row][j] != 0) break; vis[row][j] = 1; } } int countUnguarded(int m, int n, vector& guards, vector& walls) { vector grid(m, vector(n, 0)); vector vis(m, vector(n, 0)); for (auto guard : guards) { grid[guard[0]][guard[1]] = 1; } for (auto wall : walls) { grid[wall[0]][wall[1]] = -1; } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 1) { solve1(grid, vis, i, j); solve2(grid, vis, i, j); solve3(grid, vis, i, j); solve4(grid, vis, i, j); } } } int ans = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 0 && vis[i][j] == 0) ans++; } } return ans; } };
great explanation sirr🔥🔥
Aryan bhai help me for 21 days to start again to come back on DSA after 6 months of gap do keep consistently posting video I will also continue with you in the same journey
class Solution {
public:
void solve1(vector& grid, vector& vis, int i,
int j) {
int m = grid.size(), n = grid[0].size();
for (int col = j + 1; col < n; col++) {
if (grid[i][col] != 0)
break;
vis[i][col] = 1;
}
}
void solve2(vector& grid, vector& vis, int i,
int j) {
int m = grid.size(), n = grid[0].size();
for (int col = j - 1; col >= 0; col--) {
if (grid[i][col] != 0)
break;
vis[i][col] = 1;
}
}
void solve3(vector& grid, vector& vis, int i,
int j) {
int m = grid.size(), n = grid[0].size();
for (int row = i + 1; row < m; row++) {
if (grid[row][j] != 0)
break;
vis[row][j] = 1;
}
}
void solve4(vector& grid, vector& vis, int i,
int j) {
int m = grid.size(), n = grid[0].size();
for (int row = i - 1; row >= 0; row--) {
if (grid[row][j] != 0)
break;
vis[row][j] = 1;
}
}
int countUnguarded(int m, int n, vector& guards,
vector& walls) {
vector grid(m, vector(n, 0));
vector vis(m, vector(n, 0));
for (auto guard : guards) {
grid[guard[0]][guard[1]] = 1;
}
for (auto wall : walls) {
grid[wall[0]][wall[1]] = -1;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (grid[i][j] == 1) {
solve1(grid, vis, i, j);
solve2(grid, vis, i, j);
solve3(grid, vis, i, j);
solve4(grid, vis, i, j);
}
}
}
int ans = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (grid[i][j] == 0 && vis[i][j] == 0)
ans++;
}
}
return ans;
}
};
Brooo
Y u changed to confluent??
3 digit % increase + Learning Opportunities & Growth sir :)
@ARYANMITTAL 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥