DFS solution(same as number of islands)
Intuition\n Describe your first thoughts on how to solve this problem. \nEasy to understand if you solve the problem named number of islands  before ...\n\n# Co
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEasy to understand if you solve the problem named number of islands  before ...\n\n# Complexity\n- Time complexity:<b>O(N*M)</B>\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:<b>O(N*M)</B>\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    void fill(vector<vector<int>>& v,vector<vector<int>> x,int index){\n        for(int k=0;k<3;k++){\n        v[index].push_back(x[0][k]);\n        v[index+1].push_back(x[1][k]);\n        v[index+2].push_back(x[2][k]);\n        }\n    }\n    void dfs(vector<vector<int>>&v , int i,int j){\n        vector<int> x={1,0,-1,0};\n        vector<int> y={0,1,0,-1};\n        v[i][j]=1;\n        for(int k=0;k<4;k++){\n            int i1=i+x[k];\n            int j1=j+y[k];\n            if(i1>=0 && j1>=0 && i1<v.size() && j1<v[0].size() && v[i1][j1]==0){\n                dfs(v,i1,j1);\n            }\n        }\n    }\n    int regionsBySlashes(vector<string>& grid) {\n        for(auto it:grid){\n            cout<<it<<endl;\n        }\n        int n=grid.size();\n        vector<vector<int>> v(3*n);\n        vector<vector<int>> e={{0,0,0},{0,0,0},{0,0,0}};\n        vector<vector<int>> a={{1,0,0},{0,1,0},{0,0,1}};\n        vector<vector<int>> b={{0,0,1},{0,1,0},{1,0,0}};\n        int index=0;\n        for(int i=0;i<n;i++){\n            for(int j=0;j<grid[i].size();j++){\n                // cout<<grid[i][j];\n                if(grid[i][j]==\' \') fill(v,e,index);\n                else if(grid[i][j]==\'/\') fill(v,b,index);\n                else{\n                    fill(v,a,index);\n                }\n            }\n            index+=3;\n        }\n        for(int i=0;i<v.size();i++){\n            for(int j=0;j<v[0].size();j++){\n                cout<<v[i][j]<<" ";\n            }\n            cout<<endl;\n        }\n        int ans=0;\n        for(int i=0;i<v.size();i++){\n            for(int j=0;j<v[0].size();j++){\n                if(v[i][j]==0){\n                    ans++;\n                    dfs(v,i,j);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Matrix', 'C++']