Java Simple and easy to understand solution, 4 ms, faster than 88.95%, clean code with comments
PLEASE UPVOTE IF YOU LIKE THIS SOLUTION\n\n\n\nclass Solution {\n    String[] grid;\n    int rows;\n    int cols;\n    boolean[][][] visited;\n    \n    public 
**PLEASE UPVOTE IF YOU LIKE THIS SOLUTION**\n\n\n```\nclass Solution {\n    String[] grid;\n    int rows;\n    int cols;\n    boolean[][][] visited;\n    \n    public int regionsBySlashes(String[] grid) {\n        this.grid = grid;\n        rows = grid.length;\n        cols = grid[0].length();\n        \n        visited = new boolean[rows][cols][4];\n        \n        int regionCount = 0;\n        \n        //iterater through each triangle of cell\n        for(int row = 0; row < rows; row++){\n            for(int col = 0; col < cols; col++){\n                \n                for(int type = 0; type < 4; type++){\n                    \n                    if(visited[row][col][type] == false){\n                        dfs(row, col, type);\n                        regionCount++;\n                    }\n                }\n            }\n        }\n        \n        return regionCount;\n    }\n\n    \n\n    \n    private void dfs(int row, int col, int type){\n\n        if(!isInsideGrid(row, col) || visited[row][col][type] == true)\n            return;\n        \n        //mark as visited\n        visited[row][col][type] = true;\n\n        \n        \n        if(type == 0){\n            //move up\n            dfs(row - 1, col, 2);\n            \n        }else if(type == 2){\n            //move down\n            dfs(row + 1, col, 0);\n            \n        }else if(type == 1){\n            //move right\n            dfs(row, col + 1, 3);\n            \n        }else if(type == 3){\n            //move left\n            dfs(row, col - 1, 1);\n        }\n        \n\n        if(grid[row].charAt(col) != \'/\'){\n            //0 ^ 1 = 1\n            //1 ^ 1 = 0\n            //2 ^ 1 = 3\n            //3 ^ 1 = 2\n        \n            dfs(row, col, (type ^ 1));\n        \n        }\n        \n        if(grid[row].charAt(col) != \'\\\\\'){\n            //0 ^ 3 = 3\n            //1 ^ 3 = 2\n            //2 ^ 3 = 1\n            //3 ^ 3 = 0\n            \n            dfs(row, col, (type ^ 3));\n        \n        }\n            \n        \n        \n    }\n    \n    \n    private boolean isInsideGrid(int row, int col){\n        \n        return row >= 0 && row < rows && col >= 0 && col < cols; \n    }\n}\n```
['Depth-First Search', 'Java']