C++|DFS
class Solution {\npublic:\n    \n    void dfs(int curr,vector>& G,vector &vis)\n    {\n      \n        if(vis[curr]==1)\n           return;\n        vis[curr]=1
class Solution {\npublic:\n    \n    void dfs(int curr,vector<vector<int>>& G,vector<int> &vis)\n    {\n      \n        if(vis[curr]==1)\n           return;\n        vis[curr]=1;\n        int i;\n        for(i=0;i<G.size();i++)\n        {\n          \n            if(G[curr][i]&&vis[i]==0)\n                dfs(i,G,vis);\n        }\n    }\n    int minMalwareSpread(vector<vector<int>>& G, vector<int>& initial) {\n            int n=G.size();\n        int i,j,ans=0,idx=-1;\n        sort(initial.begin(),initial.end());\n        for(i=0;i<initial.size();i++)\n        {\n            vector<int> vis(n,0);\n            int remove=initial[i];//removing\n            vis[remove]=1;//marking the removed so that it does not get visited \n            for(j=0;j<initial.size();j++)\n            {\n                if(vis[initial[j]]==0)\n            dfs(initial[j],G,vis);\n                \n            }\n            \n            int c=0;\n            for(auto x:vis)\n            {\n                c+=x;\n            }\n            if(ans<(n-c+1))\n            {\n                ans=n-c+1;\n                idx=remove;\n            }\n            \n        }\n        return idx;\n    }\n};
['Depth-First Search', 'C']