From 2ee28115bf40b609c29d0382fe93d39cb44e14c8 Mon Sep 17 00:00:00 2001 From: MariaThomson <62303971+MariaThomson@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:21:29 +0530 Subject: [PATCH] added number of islands program --- CPP/Number of Islands.cpp | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 CPP/Number of Islands.cpp diff --git a/CPP/Number of Islands.cpp b/CPP/Number of Islands.cpp new file mode 100644 index 0000000..1bfba34 --- /dev/null +++ b/CPP/Number of Islands.cpp @@ -0,0 +1,75 @@ +//Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. + + +class Solution { + struct node{ + int x; + int y; + node(int _x,int _y) + { + x=_x; + y=_y; + } +}; + public: + int visited[1000][1000]; +void bfs(int i,int j,int n,int m,vector>& grid) +{ + queueq; + q.push(node(i,j)); + visited[i][j]=1; + cout<=0 && c=0 && d>& grid) { + int n=grid.size(); + int m=grid[0].size(); + + for(int i=0;i