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; +} +};