NeetCode #156LC-2257MediumArrays & Hashing
← Back to All Problems#156 · #2257 · Count Unguarded Cells in the Grid(统计网格图中没有被保卫的格子数)
📌 Problem Statement & Constraints
You are given two integers
m and n and a 2D grid where 0 is an empty cell, 1 is a guard and 2 is a wall. A guard sees every cell in the four cardinal directions until blocked by a wall or another guard. Return the number of unguarded cells. Constraints: 1 <= m, n <= 10^5, 2 <= m * n <= 10^5.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!