Same as no of island problem || C++ || DFS
\nclass Solution {\npublic:\n    void dfs(vector<vector<int>>&newgrid,int x,int y){\n        \n        if(x<0 || y<0 || x>=newgrid.size() || y>=newgrid[x].size(
```\nclass Solution {\npublic:\n    void dfs(vector<vector<int>>&newgrid,int x,int y){\n        \n        if(x<0 || y<0 || x>=newgrid.size() || y>=newgrid[x].size())\n            return;\n        if(newgrid[x][y]!=0)\n            return;\n        newgrid[x][y]=1;\n        dfs(newgrid,x+1,y);\n        dfs(newgrid,x,y+1);\n        dfs(newgrid,x,y-1);\n        dfs(newgrid,x-1,y);\n    }\n    \n    int regionsBySlashes(vector<string>& grid) {\n       int n=grid.size();\n        vector<vector<int>> newgrid(3*n,vector<int>(3*n,0) );\n        int m=grid[0].size();\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                if(grid[i][j]==\'/\'){\n                    newgrid[3*i][3*j+2]=1;\n                    newgrid[3*i+1][3*j+1]=1;\n                    newgrid[3*i+2][3*j]=1;\n                }\n                else if(grid[i][j]==\'\\\\\'){\n                    newgrid[3*i][3*j]=1;\n                    newgrid[3*i+1][3*j+1]=1;\n                    newgrid[3*i+2][3*j+2]=1;\n                }\n            }\n        }\n        int ans=0;\n        for(int i=0;i<newgrid.size();i++){\n            for(int j=0;j<newgrid[i].size();j++){\n                if(newgrid[i][j]==0){\n                    dfs(newgrid,i,j);\n                    ans++;\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
[]