Short and Concise C++ Solution using Number of Island Technique||Explanation given✅✅
Approach\n So here what I did is that I made a bigger matrix vec in a way that for every character in the grid it is 3 times magnified but in 0s and 1s i.e. \ns
# Approach\n So here what I did is that I made a bigger matrix $$vec$$ in a way that for every character in the grid it is 3 times magnified but in 0s and 1s i.e. \nsuppose the character is \'/\' then in vec it will be \n0 0 1\n0 1 0\n1 0 0\nand if the character was \'\\\\\' then in vec it will be \n1 0 0\n0 1 0\n0 0 1\nand the rest of the characters will be \n0 0 0\n0 0 0\n0 0 0\nWe can notice it is in the form of number of island problem so we make a variable $$res=0$$ (which we are eventually going to return) and traverse the vec and whenever we find element in the vec is 0 we call the $$helper$$ function and increment the res by 1. In the helper function, if the element is already 1 or it is not inside the boundary of vec, we return otherwise we make the element 1 and also call the helper function for its surrounding elements. We then return the res.\n\n# Code\n```\nclass Solution {\npublic:\n    void helper(int i,int j,int size,vector<vector<int>>&vec){\n        if(i<0 || i>=size ||j<0 ||j>=size || vec[i][j]==1) return;\n        vec[i][j]=1;\n        helper(i-1,j,size,vec);\n        helper(i+1,j,size,vec);\n        helper(i,j-1,size,vec);\n        helper(i,j+1,size,vec);\n    }\n    int regionsBySlashes(vector<string>& grid) {\n        int n= grid.size();\n        vector<vector<int>> vec(3*n,vector<int>(3*n,0));\n        for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                int xc=3*j;\n                int yc=3*i;\n                if(grid[i][j]==\'/\'){\n                    vec[yc][xc+2]=1;\n                    vec[yc+1][xc+1]=1;\n                    vec[yc+2][xc]=1;\n                }\n                else if(grid[i][j]==\'\\\\\'){\n                    vec[yc][xc]=1;\n                    vec[yc+1][xc+1]=1;\n                    vec[yc+2][xc+2]=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(vec[i][j]==0){\n                    res++;\n                    helper(i,j,3*n,vec);\n                }\n            }\n        }\n        return res;\n    }\n};\n  //       PLEASE UPVOTE IF IT HELPS..THANK YOU\n```
['C++']