C++ DFS Approach
Taking idea from the @votrubac\'s approach.\n\nclass Solution {\npublic:\n    void dfs(int i,int j,int m,vector<vector<int>>&grid){\n        if(i<0 || j<0 || i>
Taking idea from the @votrubac\'s approach.\n```\nclass Solution {\npublic:\n    void dfs(int i,int j,int m,vector<vector<int>>&grid){\n        if(i<0 || j<0 || i>=m || j>=m || grid[i][j]==1){\n           return;\n        }\n        grid[i][j]=1;\n           dfs(i+1,j,m,grid);\n           dfs(i-1,j,m,grid);\n           dfs(i,j+1,m,grid);\n           dfs(i,j-1,m,grid);\n\n    }\n    int regionsBySlashes(vector<string>& grid) {\n        int ans=0;\n        int n=grid.size();\n        vector<vector<int>>g(n*3,vector<int>(n*3,0));\n        for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                if(grid[i][j]==\'/\'){\n                    g[i*3][j*3+2]=1;\n                    g[i*3+1][j*3+1]=1;\n                    g[i*3+2][j*3]=1;\n                }\n                if(grid[i][j]==\'\\\\\'){\n                    g[i*3][j*3]=1;\n                    g[i*3+1][j*3+1]=1;\n                    g[i*3+2][j*3+2]=1;\n                }\n            }\n        }\n        int m=g.size();\n        for(int i=0;i<m;i++){\n            for(int j=0;j<m;j++){\n                if(g[i][j]==0){\n                    dfs(i,j,m,g);\n                    ans++;\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
[]