clean code using dfs
Complexity\n- Time complexity: O(9 * n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(9 * n^2)\n Add your space complexity here, e.g. O
# Complexity\n- Time complexity: O(9 * n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(9 * n^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public void dfs(int arr[][], int i, int j) {\n        if (i < 0 || i >= arr.length || j < 0 || j >= arr[0].length || arr[i][j] == 1) return;\n\n        arr[i][j] = 1;\n        dfs(arr, i-1, j);\n        dfs(arr, i+1, j);\n        dfs(arr, i, j+1);\n        dfs(arr, i, j-1);\n\n        return;\n    }\n    public int regionsBySlashes(String[] grid) {\n        int n = grid.length;\n        int arr[][] = new int[3*n][3*n];\n\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < grid[i].length(); j++) {\n                if (grid[i].charAt(j) == \'\\\\\') {\n                    arr[3*i][3*j] = 1;\n                    arr[(3*i)+1][(3*j)+1] = 1;\n                    arr[(3*i)+2][(3*j)+2] = 1; \n                } else if (grid[i].charAt(j) == \'/\') {\n                    arr[3*i][(3*j)+2] = 1;\n                    arr[(3*i)+1][(3*j)+1] = 1;\n                    arr[(3*i)+2][(3*j)] = 1;\n                }\n            }\n        }\n        int res = 0;\n        for (int i = 0; i < 3*n; i++) {\n            for (int j = 0; j < 3*n; j++) {\n                if (arr[i][j] == 0) {\n                    dfs(arr, i, j);\n                    res++;\n                }\n            }\n        }\n        return res;\n    }\n}\n```
['Array', 'Hash Table', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Matrix', 'Java']