Simple DFS || C++
Intuition\nRemove one infected node at a time and simulate the spread of malware. The one that gives the minimum M(initial) is the answer.\n# Code\n\nclass Solu
# Intuition\nRemove one infected node at a time and simulate the spread of malware. The one that gives the minimum M(initial) is the answer.\n# Code\n```\nclass Solution \n{\npublic:\n    void dfs(int node, vector<int> adj[], vector<int>& vis)\n    {\n        if(vis[node]) return;\n        vis[node]=1;\n        for(auto it: adj[node])\n        {\n            dfs(it,adj,vis);\n        }\n    }\n    int minMalwareSpread(vector<vector<int>>& graph, vector<int>& initial) \n    {\n        int n=graph.size();\n        int mn=400;\n        int ans=-1;\n        sort(initial.begin(),initial.end());\n        for(auto i: initial)\n        {\n            vector<vector<int>> temp=graph;\n            for(int x=0; x<n; x++) temp[x][i]=0;\n            for(int y=0; y<n; y++) temp[i][y]=0;\n            vector<int> adj[n];\n            for(int x=0; x<n; x++)\n            {\n                for(int y=0; y<n; y++)\n                {\n                    if(temp[x][y]) \n                    {\n                        adj[x].push_back(y);\n                        adj[y].push_back(x);\n                    }\n                }\n            }\n            vector<int> vis(n,0);\n            for(auto node: initial)\n            {\n                dfs(node,adj,vis);\n            }\n            int cnt=0;\n            for(int x=0; x<n; x++)\n            {\n                if(vis[x]) cnt++;\n            }\n            if(cnt<mn)\n            {\n                mn=cnt;\n                ans=i;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']