Java Solution | Using DFS
\nclass Solution {\n    private void dfs(int[][] graph, int row, int col) {\n\t\tif (row < 0 || row >= graph.length || col < 0 || col >= graph.length || graph[r
```\nclass Solution {\n    private void dfs(int[][] graph, int row, int col) {\n\t\tif (row < 0 || row >= graph.length || col < 0 || col >= graph.length || graph[row][col] != 0) {\n\t\t\treturn;\n\t\t}\n\t\tgraph[row][col] = 1;\n\t\tdfs(graph, row - 1, col);\n\t\tdfs(graph, row + 1, col);\n\t\tdfs(graph, row, col - 1);\n\t\tdfs(graph, row, col + 1);\n\t}\n\n\tpublic int regionsBySlashes(String[] grid) {\n\t\tint n = grid.length;\n\t\tint[][] graph = new int[n * 3][n * 3];\n\t\tfor (int row = 0; row < n; ++row) {\n\t\t\tfor (int col = 0; col < n; ++col) {\n\t\t\t\tif (grid[row].charAt(col) == \'/\') {\n\t\t\t\t\tgraph[row * 3][col * 3 + 2] = 1;\n\t\t\t\t\tgraph[row * 3 + 1][col * 3 + 1] = 1;\n\t\t\t\t\tgraph[row * 3 + 2][col * 3] = 1;\n\t\t\t\t} else if (grid[row].charAt(col) == \'\\\\\') {\n\t\t\t\t\tgraph[row * 3][col * 3] = 1;\n\t\t\t\t\tgraph[row * 3 + 1][col * 3 + 1] = 1;\n\t\t\t\t\tgraph[row * 3 + 2][col * 3 + 2] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// for (int row = 0; row < n * 3; ++row) {\n\t\t// \tfor (int col = 0; col < n * 3; ++col) {\n\t\t// \t\tSystem.out.print(graph[row][col] + " ");\n\t\t// \t}\n\t\t// \tSystem.out.println();\n\t\t// }\n\t\tint regions = 0;\n\t\tfor (int row = 0; row < n * 3; ++row) {\n\t\t\tfor (int col = 0; col < n * 3; ++col) {\n\t\t\t\tif (graph[row][col] != 1) {\n\t\t\t\t\tdfs(graph, row, col);\n\t\t\t\t\tregions++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn regions;\n\t}\n}\n```
['Depth-First Search', 'Graph', 'Recursion', 'Java']