From 949fed6c8a52e6309f2f2126f5aa0be138b77db2 Mon Sep 17 00:00:00 2001 From: NIDHI UPMAN <130860182+nidhiupman568@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:41:34 +0530 Subject: [PATCH] Create Count Unguarded Cells in the Grid --- Count Unguarded Cells in the Grid | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Count Unguarded Cells in the Grid diff --git a/Count Unguarded Cells in the Grid b/Count Unguarded Cells in the Grid new file mode 100644 index 0000000..79d4d63 --- /dev/null +++ b/Count Unguarded Cells in the Grid @@ -0,0 +1,12 @@ +class Solution { +public: + int countUnguarded(int m, int n, vector>& guards, vector>& walls) { + // Initialize grid with zeros + int g[m][n]; + memset(g, 0, sizeof(g)); + + // Mark guards and walls as 2 + for (auto& e : guards) { + g[e[0]][e[1]] = 2; +… } +};