Java Clean Solution Using DFS(Recursion)
Complexity\n- Time complexity:O(nm9 * (4alpha))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(nm*9 + K)\n Add your space complexity here, 
# Complexity\n- Time complexity:$$O(n*m*9 * (4*alpha))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n*m*9 + K)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n    private int solveDFS(int[][] dp, int i, int j) {\n        // edge\n        if (Math.min(i, j) < 0 || Math.max(i, j) >= dp.length || dp[i][j] != 0) {\n            return 0;\n        }\n\n        dp[i][j] = 1;\n        return (1 + solveDFS(dp, i, j + 1) + solveDFS(dp, i, j - 1)\n                + solveDFS(dp, i + 1, j) + solveDFS(dp, i - 1, j));\n    }\n\n    public int regionsBySlashes(String[] grid) {\n        int n = grid.length;\n\n        int[][] dp = new int[n * 3][n * 3];\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < n; j++) {\n                if (grid[i].charAt(j) == \'/\') {\n                    dp[i * 3][j * 3 + 2] = dp[i * 3 + 1][j * 3 + 1] = dp[i * 3 + 2][j * 3] = 1;\n                } else if (grid[i].charAt(j) == \'\\\\\') {\n                    dp[i * 3][j * 3] = dp[i * 3 + 1][j * 3 + 1] = dp[i * 3 + 2][j * 3 + 2] = 1;\n                }\n            }\n        }\n\n        int res = 0;\n        for (int i = 0; i < n * 3; i++) {\n            for (int j = 0; j < 3 * n; j++) {\n                res += solveDFS(dp, i, j) > 0 ? 1 : 0;\n            }\n        }\n        return res;\n    }\n}\n```
['Array', 'Hash Table', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Matrix', 'Java']