C++ BFS Solution
Count those nodes which can infected only by 1 node.\nRemoving those node would be better which can infect maximum nodes alone.\ncpp\nclass Solution {\npublic:\
Count those nodes which can infected only by 1 node.\nRemoving those node would be better which can infect maximum nodes alone.\n```cpp\nclass Solution {\npublic:\n    int minMalwareSpread(vector<vector<int>>& graph, vector<int>& initial) {\n        int n=graph.size();\n        unordered_map<int,vector<int>> count;\n        vector<bool> is_infected(n);\n        for(int &u:initial)\n            is_infected[u]=1;\n        for(int &u:initial){\n            vector<bool> visited(n);\n            queue<int> q;\n            q.push(u);\n            while(q.size()){\n                int v=q.front();\n                q.pop();\n                for(int i=0;i<n;i++){\n                    if(graph[v][i]==0 or visited[i] or is_infected[i])\n                        continue;\n                    visited[i]=1;\n                    count[i].push_back(u);\n                    q.push(i);\n                }\n            }\n        }\n        vector<int> ans(n);\n        for(auto &[u,arr]:count){\n            if(arr.size()==1)\n                ans[arr.front()]++;\n        }\n        int mxm=*max_element(ans.begin(),ans.end());  \n        if(mxm==0){\n            return *min_element(initial.begin(),initial.end());\n        }\n        return find(ans.begin(),ans.end(),mxm)-ans.begin();\n    }\n};\n```
['Breadth-First Search']