Mark the boundary and then the problem become Number of Islands (dfs or bfs)
First mark the boundary by painting [n * 3][m * 3] grid, then use the algorithm count number of island (leetcode200) using either bfs or dfs\nUsing a 3X3 array 
First mark the boundary by painting [n * 3][m * 3] grid, then use the algorithm count number of island ([leetcode200](https://leetcode.com/problems/number-of-islands/)) using either bfs or dfs\nUsing a 3X3 array to represent \'/\' or \'\\\\\'\n0 0 1            \n0 1 0               \n1 0 0        \n\n1 0 0\n0 1 0\n0 0 1\nWhy need to use 3x3 array to represent \'/\' or \'\\\\\'? For example ["//","/ "]\nuse 1d: can\'t not distinct individual component\n1 1\n1 0\nuse 2d: some connected area was isolated \n0 1 0 1\n1 0 1 0\n0 1 0 0\n1 0 0 0\n\nuse 3d:\n0 0 1 0 0 1\n0 1 0 0 1 0\n1 0 0 1 0 0\n0 0 1 0 0 0\n0 1 0 0 0 0\n1 0 0 0 0 0\nuse 4d or more: it works, but not necessary\n```\nclass Solution {\n    public int regionsBySlashes(String[] grid) {\n        int n = grid.length, m = grid[0].length();\n        int cnt = 0;\n        int[][] g = new int[n*3][m*3];\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                if(grid[i].charAt(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                }else if(grid[i].charAt(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        for(int i=0;i<g.length;i++){\n            for(int j=0;j<g[0].length;j++){\n                if(g[i][j]==0){\n                    dfs(g,i,j);\n                    cnt++;\n                }\n            }\n        }\n        return cnt;\n    }\n    \n    void dfs(int[][] g, int i, int j){\n        int n = g.length, m = g[0].length;\n        if(i<0 || i>=n || j<0 || j>=m || g[i][j]==1) return;\n        g[i][j]=1;\n        int d[] = {0,-1,0,1,0};\n        for(int k=0;k<4;k++){\n            dfs(g,i+d[k],j+d[k+1]);\n        }\n    }\n}\n```
[]