shlogg · Early preview
Md Ariful Haque @mah-shamim

Count Unguarded Cells In Grid With Guards And Walls

Create a 2D grid and mark guarded cells by simulating guard vision in four directions. Count unguarded cells after processing all guards.

2257. Count Unguarded Cells in the Grid
Difficulty: Medium
Topics: Array, Matrix, Simulation
You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.
A guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed by a wall or another guard. A cell is guarded if there is at least one guard that can see it.
Return the number of...