C++ solution brute force
Remove each node from initial and find the answer to M(intitial). Take the least indexed node which has the least M(initial). I have used BFS to find out answer
Remove each node from `initial` and find the answer to `M(intitial)`. Take the least indexed node which has the least `M(initial)`. I have used BFS to find out answer to `M(initial)`.\n\nComplexity:\nTime => `O(N^3)`, where `N = number of nodes in graph`\nSpace -> `O(N)`, where `N = number of nodes in graph`\n\n```\nclass Solution {\npublic:\n    int bfs(vector<vector<int>>& graph, vector<int>& initial, int exempt){\n        int n = graph.size();\n        vector<bool> vis(n, false);\n        queue<int> q;\n        int ans = 0;\n        for(auto u: initial){\n            if(u != exempt){\n                q.push(u);\n                vis[u] = true;\n                ans++;\n            }\n        }\n        while(!q.empty()){\n            int u = q.front();\n            q.pop();\n            for(int v = 0; v < n; v++){\n                if(v != exempt && graph[u][v] && !vis[v]){\n                    q.push(v);\n                    vis[v] = true;\n                    ans++;\n                }\n            }\n        }\n        return ans;\n    }\n    int minMalwareSpread(vector<vector<int>>& graph, vector<int>& initial) {\n        sort(initial.begin(), initial.end());\n        int ans = initial[0], M = INT_MAX, curr;\n        for(auto i: initial){\n            curr = bfs(graph, initial, i);\n            if(curr < M){\n                M = curr;\n                ans = i;\n            }\n        }\n        return ans;\n    }\n};\n```
[]