From eb69a8a83480941497d17679c3477858b66f66f9 Mon Sep 17 00:00:00 2001 From: chayan das Date: Tue, 28 Oct 2025 23:29:58 +0530 Subject: [PATCH] Create 28 October Distance of nearest cell having 1 --- 28 October Distance of nearest cell having 1 | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 28 October Distance of nearest cell having 1 diff --git a/28 October Distance of nearest cell having 1 b/28 October Distance of nearest cell having 1 new file mode 100644 index 0000000..5aab5d6 --- /dev/null +++ b/28 October Distance of nearest cell having 1 @@ -0,0 +1,47 @@ +class Solution { + public: + vector>nearest(vector>grid) +{ + int row = grid.size(); + int col = grid[0].size(); + + queue> q; + vector> ans(row,vector(col,-1)); + + for(int i=0;i=row||nb>=col||ans[na][nb]!=-1) continue; + q.push({na,nb}); + ans[na][nb]=ans[a][b]+1; + } + } + } + return ans; +} +};