[C++]  DFS solution + Pixel upscaling [Detailed Explanation]
\n/*\n    https://leetcode.com/problems/regions-cut-by-slashes/\n    \n    TC: O(N^2)\n    SC: O(N^2)\n    \n    Idea is to map the grid pixels to a higher reso
```\n/*\n    https://leetcode.com/problems/regions-cut-by-slashes/\n    \n    TC: O(N^2)\n    SC: O(N^2)\n    \n    Idea is to map the grid pixels to a higher resolution matrix. Doing so gives the \n    necessary space between the pixels for traversal and figuring clear boundaries.\n    \n    For each slash value, we map it to a 3 * 3 grid, where three 1s are used to represent it.\n    Eg: \'/\'\n    001\n    010\n    100\n    \n    \'\\\'\n    100\n    010\n    001\n    \n    ["/ ", "\\\\ "]\n    001000\n    010000\n    100000\n    100000\n    010000\n    001000\n    \n    The empty spaces are clearly represented with 0s and they can be traversed also since they\n    are connected together.\n    Then this problem becomes problem of finding connected components of 0s. All the slash pixels (1s)\n    form the border/obstructions in the traversal of 0s.\n    Problem becomes similar to https://leetcode.com/problems/number-of-islands/\n*/\nclass Solution {\npublic:\n    void dfs(int row, int col, vector<vector<int>>& matrix) {\n        // out of bound + already visited check (mark the empty with 1 to indicate visited)\n        if(row < 0 || row >= matrix.size() || col < 0 ||\n           col >= matrix.size() || matrix[row][col] == 1)\n            return;\n        // mark visited\n        matrix[row][col] = 1;\n        \n        dfs(row + 1, col, matrix);\n        dfs(row - 1, col, matrix);\n        dfs(row, col + 1, matrix);\n        dfs(row, col - 1, matrix);\n    }\n    \n    int regionsBySlashes(vector<string>& grid) {\n        int N = grid.size();\n        \n        // Map the graph cells to a higher resolution grid\n        // Each cell is given 3 * 3 area. This would allow to have clear\n        // boundary cells between the slashes\n        // matrix[i][j] = 0 => Empty cell, 1 => a Pixel value of slash is present\n        vector<vector<int>> matrix(N * 3, vector<int>(N * 3, 0));\n        \n        // fill the new higher resolution matrix\n        for(int row = 0; row < N; row++)\n            for(int col = 0; col < N; col++) {\n                if(grid[row][col] == \'/\') {\n                    matrix[row * 3][col * 3 + 2] = 1;\n                    matrix[row * 3 + 1][col * 3 + 1] = 1;\n                    matrix[row * 3 + 2][col * 3] = 1;\n                }\n                // \'\\\\\' is read at once and not as individual chars\n                else if(grid[row][col] == \'\\\\\') {\n                    matrix[row * 3][col * 3] = 1;\n                    matrix[row * 3 + 1][col * 3 + 1] = 1;\n                    matrix[row * 3 + 2][col * 3 + 2] = 1;\n                }\n            }\n        \n        // Now the pixel values of slashes which are represented by 1 act as boundary in \n        // the matrix. So now the matrix is filled with 0s and 1s, 0s are the empty spaces \n        // and 1s bound the empty space (0s). We now have to find the empty spaces connected to each other\n        // either horizontally or vertically.\n        int regions = 0;\n        \n        for(int row = 0; row < matrix.size(); row++)\n            for(int col= 0; col < matrix.size(); col++) \n                if(matrix[row][col] == 0) {\n                    dfs(row, col, matrix); \n                    ++regions;\n                }\n            \n        return regions;\n    }\n    \n};\n```
['Depth-First Search', 'C', 'C++']