[CPP] Clean Code for Interviews
\n\n# Code\n\n\n\nstruct Region {\n    unordered_set<int> inf;\n    unordered_set<int> non_inf;\n    int walls;\n};\nbool operator<(const Region &r,const Region
\n\n# Code\n```\n\n\nstruct Region {\n    unordered_set<int> inf;\n    unordered_set<int> non_inf;\n    int walls;\n};\nbool operator<(const Region &r,const Region &b){\n    return r.non_inf.size() < b.non_inf.size();\n}\n\nclass Solution {\npublic:\n    vector<Region> regions;   \n    vector<vector<int>> mat;\n    vector<vector<bool>> seen;\n    int n,m;\n    int comp(int i,int j) {\n        return i*m + j;\n    }\n    pair<int,int> dec(int mask) {\n        return {mask/m, mask%m};\n    }\n    int containVirus(vector<vector<int>>& isInfected) {\n        n = isInfected.size();\n        m = isInfected[0].size();\n        mat = isInfected;\n        int ans = 0;\n        while(1) {\n            seen.clear();\n            seen.resize(n,vector<bool>(m));\n            regions.clear();\n            for(int i=0;i<n;i++){\n                for(int j=0;j<m;j++){\n                    if(!seen[i][j] && mat[i][j]==1) {\n                        Region reg{.walls= 0};\n                        dfs(i,j,reg);\n                        regions.push_back(reg);\n                    }\n                }\n            }\n            if(regions.empty()) break;\n            sort(regions.begin(),regions.end());\n            auto largest = regions.back();\n            regions.pop_back();\n            ans +=largest.walls;\n            for(int mask:largest.inf){\n                auto [i,j] = dec(mask);\n                mat[i][j] = 2;\n            }\n            for(auto left_r: regions) {\n                for(int mask: left_r.non_inf){\n                    auto [i,j] = dec(mask);\n                    mat[i][j] = 1;\n                }\n            }\n        }\n        return ans;\n    }\n    void dfs(int i,int j,Region &reg) {\n        if(i<0 || j<0 || i>=n || j >=m || mat[i][j]==2) return;\n        \n        if(mat[i][j]==0) {\n            reg.non_inf.insert(comp(i,j));\n            reg.walls++;\n            return;\n        };\n        if(seen[i][j]) return;\n        seen[i][j] =1;\n        reg.inf.insert(comp(i,j));\n        \n        dfs(i+1,j,reg);\n        dfs(i,j+1,reg);\n        dfs(i-1,j,reg);\n        dfs(i,j-1,reg);\n    }\n};\n```
['C++']