[C++] | Simple DFS
\nclass Solution {\npublic:\n    int n;\n    int minMalwareSpread(vector<vector<int>>& g, vector<int>& B) {\n        n = g.size();\n        int result = INT_MAX
```\nclass Solution {\npublic:\n    int n;\n    int minMalwareSpread(vector<vector<int>>& g, vector<int>& B) {\n        n = g.size();\n        int result = INT_MAX, index = -1;\n        sort(B.begin(), B.end());\n        for(int i = 0; i < B.size(); i++){\n            int ans = helper(B[i], g, B);\n            if(ans < result){\n                result = ans;\n                index = i;\n            }\n        }\n        return B[index];\n    }\n    int counter(int cur, vector<vector<int>>& g, vector<bool> &vis){\n        if(vis[cur]) return 0;\n        vis[cur] = true;\n        int sum = 1;\n        for(int i = 0; i < n; i++)\n            if(g[cur][i])\n                sum += counter(i, g, vis);\n        return sum;\n    }\n    int helper(int cur, vector<vector<int>>& g, vector<int>& B){\n        int count = 0;\n        vector<bool> vis(n);\n        vis[cur] = true;\n        for(auto& a: B){\n            if(a != cur)\n                count += counter(a, g, vis);\n        }\n        return count;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']