2257. Count Unguarded Cells in the Grid | Simulation | Deep Time Complexity Analysis Problem

  Рет қаралды 906

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 5
@nocodelimits
@nocodelimits 3 күн бұрын
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
@Engineering.Wallah
@Engineering.Wallah 3 күн бұрын
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; } };
@Anonymous____________A721
@Anonymous____________A721 2 күн бұрын
Brooo Y u changed to confluent??
@ARYANMITTAL
@ARYANMITTAL 2 күн бұрын
3 digit % increase + Learning Opportunities & Growth sir :)
@Anonymous____________A721
@Anonymous____________A721 2 күн бұрын
@ARYANMITTAL 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
Take K of Each Character From Left and Right | Leetcode 2516
22:38
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 3,2 МЛН
Каха и лужа  #непосредственнокаха
00:15
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 51 МЛН
1861. Rotating the Box | Simulation | 2 Pointers
17:00
Aryan Mittal
Рет қаралды 877
My Unconventional Coding Story | Self-Taught
27:14
Travis Media
Рет қаралды 663 М.
1975. Maximum Matrix Sum | Pattern Recognition | Greedy
6:42
Count Unguarded Cells in the Grid | Leetcode 2257
16:19
Techdose
Рет қаралды 2,5 М.
Large Language Models explained briefly
8:48
3Blue1Brown
Рет қаралды 444 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 3,2 МЛН