C++ || Easy Video Solution
The video solution for the below code is\nhttps://youtu.be/odqdsf4YO3U\n\n# Code\n\nclass Solution {\nprivate:\n    void fillRegion(vector<vector<int>> &regions
The video solution for the below code is\nhttps://youtu.be/odqdsf4YO3U\n\n# Code\n```\nclass Solution {\nprivate:\n    void fillRegion(vector<vector<int>> &regions, int r, int c, char ch){\n        if(ch == \'/\'){\n            regions[3*r][3*c + 2] = 1;\n            regions[3*r + 1][3*c + 1] = 1;\n            regions[3*r + 2][3*c] = 1;\n        }\n        else if(ch == \'\\\\\'){\n            regions[3*r][3*c] = 1;\n            regions[3*r + 1][3*c + 1] = 1;\n            regions[3*r + 2][3*c + 2] = 1;\n        }\n    }\n    void bfs(vector<vector<int>> &regions, int r, int c){\n        int rows = regions.size();\n        int cols = regions[0].size();\n        vector<int> dr[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};\n        queue<pair<int, int>> q;\n        regions[r][c] = 1;\n        q.push({r, c});\n        while(!q.empty()){\n            auto front = q.front();\n            q.pop();\n            for(auto &ele : dr){\n                int tempR = ele[0] + front.first;\n                int tempC = ele[1] + front.second;\n                if(tempR >= 0 and tempR < rows and tempC >= 0 and tempC < cols and regions[tempR][tempC] == 0){\n                    regions[tempR][tempC] = 1;\n                    q.push({tempR, tempC});\n                }\n            }\n        }\n    }\npublic:\n    int regionsBySlashes(vector<string>& grid) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n        // \\\\\n        // " "/\n        // /" "\n        // Magnified into 3*3 grid\n        // For an empty space\n        // 0 0 0 \n        // 0 0 0\n        // 0 0 0\n\n        // For the /\n        // The grid will be\n        // 0 0 1\n        // 0 1 0\n        // 1 0 0\n\n        // For the \\\\\n        // The grid will be\n        // 1 0 0 \n        // 0 1 0 \n        // 0 0 1\n\n        // Example\n        // 0 0 0 0 0 1\n        // 0 0 0 0 1 0\n        // 0 0 0 1 0 0\n        // 0 0 1 0 0 0\n        // 0 1 0 0 0 0\n        // 1 0 0 0 0 0\n        int rows = grid.size();\n        int cols = grid[0].size();\n        vector<vector<int>> regions(3 * rows, vector<int> (3 * cols, 0));\n        for(int i = 0 ; i < rows ; i++){\n            for(int j = 0 ; j < cols ; j++){\n                fillRegion(regions, i, j, grid[i][j]);\n            }\n        }\n        int answer = 0;\n        for(int i = 0 ; i < 3 * rows ; i++){\n            for(int j = 0 ; j < 3 * cols ; j++){\n                if(regions[i][j] == 0){\n                    answer += 1;\n                    bfs(regions, i, j);\n                }\n            }\n        }\n        return answer;\n    }\n};\n```
['C++']