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

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

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 6
@nocodelimits
@nocodelimits 2 ай бұрын
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 Ай бұрын
didnt get time complexity part why 4mn and not g(m+n)?
@Engineering.Wallah
@Engineering.Wallah 2 ай бұрын
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 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
1861. Rotating the Box | Simulation | 2 Pointers
17:00
Aryan Mittal
Рет қаралды 1 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
Count Unguarded Cells in the Grid - Leetcode 2257 - Python
17:14
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 212 М.
2017. Grid Game | Prefix & Suffix Sums
16:15
Aryan Mittal
Рет қаралды 511
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 749 М.
Count Unguarded Cells in the Grid | Leetcode 2257
16:19
Techdose
Рет қаралды 2,7 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 241 М.
10 weird algorithms
9:06
Fireship
Рет қаралды 1,3 МЛН