DFS O(n^2) Time complexity
Intuition\n- just like this question\'s previous cousin, we have to remove malicious nodes, but here we also have option of remove it completely from graph.\n- 
# Intuition\n- just like this question\'s previous cousin, we have to remove malicious nodes, but here we also have option of remove it completely from graph.\n- We can\'t traverse through this node, this is like a dead person in this question, so it can\'t be infected anyway.\n- In it\'s  cousin question it is the healthy person you can say that, once any node is infected this guy get\'s infected if he is connected to any infected node.\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    unordered_map<int,vector<int>> adj;\n    int dfs(int node, vector<bool> &visited, int remove_node) {\n        visited[node] = true;\n        int size = 1;\n        for(auto &child : adj[node]) {\n            if(child != remove_node && !visited[child]) {\n                size += dfs(child, visited, remove_node);\n            }\n        }\n        return size;\n    }\n    int minMalwareSpread(vector<vector<int>>& graph, vector<int>& initial) {\n        int n = graph.size();\n        for(int i = 0;i < n;i++) {\n            for(int j = 0;j < n;j++) {\n                if(graph[i][j] == 1) {\n                    adj[i].push_back(j);\n                }\n            }\n        }\n        int sz = initial.size();\n        int mi = INT_MAX;\n        int ind = -1;\n        sort(initial.begin(),initial.end());\n        for(int i = 0; i < sz;i++) {\n            int remove_node = initial[i];\n            vector<bool> visited(n,false);\n            int total_nodes = 0;\n            for(int j = 0;j < sz;j++) {\n                if(initial[j] != remove_node && !visited[initial[j]]) {\n                    total_nodes += dfs(initial[j], visited, remove_node);\n                }\n            }\n            // cout << total_nodes << \' \' << remove_node << endl;\n            if(mi > total_nodes) {\n                mi = total_nodes;\n                ind = remove_node;\n            }\n            // if(mi == total_nodes) {\n            //     mi = min(mi, remove_node);\n            // }\n        }\n        return ind;\n    }\n};\n```
['C++']