diff --git a/Graphs/DistanceofNearestCellHaving1.cpp b/Graphs/DistanceofNearestCellHaving1.cpp new file mode 100644 index 0000000..8c0d8d3 --- /dev/null +++ b/Graphs/DistanceofNearestCellHaving1.cpp @@ -0,0 +1,42 @@ +class Solution +{ + public: + //Function to find distance of nearest 1 in the grid for each cell. + vector>nearest(vector>grid) + { + // Code here + int n=grid.size(),m=grid[0].size(); + vector>ans(n,vector(m,0)); + vector>visited(n,vector(m,0)); + queue,int>>q; + for(int i=0;i=0 && nrow=0 && ncol