[Simple DFS, C++]
Simple and self explainatory\n\nclass Solution {\npublic:\n    \n    void dfs(vector<vector<int>> &mat, int i, int j){\n        int n = mat.size();\n        if(
Simple and self explainatory\n```\nclass Solution {\npublic:\n    \n    void dfs(vector<vector<int>> &mat, int i, int j){\n        int n = mat.size();\n        if(i>=0 && j>=0 && i<n && j<n && mat[i][j]){\n            mat[i][j] = 0;\n            dfs(mat, i+1, j);\n            dfs(mat, i-1, j);\n            dfs(mat, i, j+1);\n            dfs(mat, i, j-1);\n        }\n    }\n    \n    int regionsBySlashes(vector<string>& g) {\n        int n = g.size();\n        vector<vector<int>> mat(n*3 , vector<int>(n*3, 1));\n        \n        for(int i = 0; i<n; i++){\n            for(int j = 0; j<n; j++){\n                if(g[i][j] == \'/\'){\n                    mat[i*3][j*3 + 2] = mat[i*3 + 1][j*3 + 1] = mat[i*3 + 2][j*3] = 0;\n                }\n                else if(g[i][j] == \'\\\\\'){\n                    mat[i*3][j*3] = mat[i*3 + 1][j*3 + 1] = mat[i*3 + 2][j*3 + 2] = 0;\n                }\n            }\n        }\n        int count  = 0, N = n*3;\n        for(int i = 0; i<N; i++){\n            for(int j = 0; j<N; j++){\n                if(mat[i][j]){\n                    count++;\n                    dfs(mat, i, j);\n                }\n            }\n        }\n        return count;\n    }\n};\n```
['Depth-First Search']