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

  Рет қаралды 1,015

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 6
@nocodelimits
@nocodelimits Ай бұрын
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
@parasmehndiratta
@parasmehndiratta 23 күн бұрын
didnt get time complexity part why 4mn and not g(m+n)?
@Engineering.Wallah
@Engineering.Wallah Ай бұрын
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 Ай бұрын
Brooo Y u changed to confluent??
@ARYANMITTAL
@ARYANMITTAL Ай бұрын
3 digit % increase + Learning Opportunities & Growth sir :)
@Anonymous____________A721
@Anonymous____________A721 Ай бұрын
@ARYANMITTAL 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
1861. Rotating the Box | Simulation | 2 Pointers
17:00
Aryan Mittal
Рет қаралды 998
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
What P vs NP is actually about
17:58
Polylog
Рет қаралды 144 М.
773. Sliding Puzzle | BFS | Graph Traversal | Matrix | Array
15:06
Aryan Mittal
Рет қаралды 2,1 М.
Visualizing transformers and attention | Talk for TNG Big Tech Day '24
57:45
Count Unguarded Cells in the Grid - Leetcode 2257 - Python
17:14
3413. Maximum Coins From K Consecutive Bags | Sliding Interval Hard
23:34