C++ Easy and Clean code || Fully explained || UNION FIND
Visualize the given n * n matrix as points .\nIf there is n size matrix the we will be having n n dots representing each intersecting points of the matrix.\nAs 
Visualize the given n * n matrix as points .\nIf there is n size matrix the we will be having n* n dots representing each intersecting points of the matrix.\nAs we iterate over the matrix we join the dots according to the char present in matrix.\n\nIf we found a cycle then that is a seperate component.\nWhenever we encounter a \'/ \' or \'\\\\\'  we calculate the points that will get connected by the character,if the points are already in the same set that means we r having a cycle thus we increase the counter by one.\n\n   **UPVOTE IF YOU FOUND IT USEFUL!!**\n\n```\n\nclass Solution {\npublic:\n    int find(int node,vector<int>&par)  // finding parent function\n    {\n        if(par[node]==node)return node;\n        return par[node]=find(par[node],par);\n    }\n    void unionn(int a,int b,int &cnt,vector<int>&rank,vector<int>&par)\n    {\n        a=find(a,par);            //uniting the dots (UNION FUNCTION)\n        b=find(b,par);\n        \n        if(a!=b)\n        {\n            if(rank[a]>rank[b])par[b]=a;\n            else if(rank[b]>rank[a])par[a]=b;\n            else{\n                par[b]=a;\n                rank[a]++;\n            }\n        }\n        else\n            cnt++;            //  if the dots are already in the same set ie they are forming cycle and thus is                                   a seperate component.\n                              //  Hence increase the cnt\n    }\n    int regionsBySlashes(vector<string>& grid) {\n        int n=grid.size();\n        int dot=n+1;\n        int cnt=1;   // intial count is 1 because the grid without any partitions is also a component.\n        \n        vector<int>par(dot*dot);\n        vector<int>rank(dot*dot);\n        \n        for(int i=0;i<dot*dot;i++)par[i]=i;     // intializing the parent and ranks of all dots.\n        for(int i=0;i<dot*dot;i++)rank[i]=1;\n        \n        for(int i=0;i<dot;i++)\n        {\n            for(int j=0;j<dot;j++)\n            {\n                if(i==0 || j==0 || i==dot-1 || j==dot-1)      // initially all the boundary dots are connected \n                {                                            // So we take union of all of them with 0.\n                     int dotno=(i*dot)+j;                  // connecting all boundar dots to leftmost dot(ie 0)\n                    if(dotno!=0)unionn(0,dotno,cnt,rank,par);\n                }\n            }\n        }\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(grid[i][j]==\'/\')\n                {\n                    int dot1=(i*dot)+(j+1);      // calculating the corresponding dots that will get connected.\n                    int dot2=((i+1)*dot)+j;    \n                     unionn(dot1,dot2,cnt,rank,par);   // connecting them\n                    \n                }\n                else if(grid[i][j]==\'\\\\\')\n                {\n                    int dot1=(i*dot)+j;\n                    int dot2=((i+1)*dot)+(j+1);\n                    unionn(dot1,dot2,cnt,rank,par);   \n                }\n           }\n        }\n        return cnt;\n        \n}\n};\n```
['Union Find', 'C', 'C++']