C++ code using BFS
\n# Code\n\nclass Solution {\npublic:\n    int getInfected(vector<int>adj[], vector<int>&initial, int ignore, int n){\n        vector<int>arr(n, 0);\n        qu
\n# Code\n```\nclass Solution {\npublic:\n    int getInfected(vector<int>adj[], vector<int>&initial, int ignore, int n){\n        vector<int>arr(n, 0);\n        queue<int>q;\n\n        for(int i=0;i<initial.size();i++){\n            if(initial[i] == ignore)\n                continue;\n            arr[initial[i]] = 1;\n            q.push(initial[i]);\n        }\n\n        while(!q.empty()){\n            int temp = q.front();\n            q.pop();\n\n            for(auto it: adj[temp]){\n                if(it == ignore)    continue;\n                if(arr[it] == 0){\n                    arr[it] = 1;\n                    q.push(it);\n                }\n            }\n        }\n\n        int count = 0;\n        for(auto it: arr){\n            if(it == 1)\n                ++count;\n        }\n\n        return count;\n    }\n\n    int minMalwareSpread(vector<vector<int>>& graph, vector<int>& initial) {\n        int n = graph.size();\n        vector<int>adj[n];\n\n        sort(initial.begin(), initial.end());\n\n        for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                if(i == j)  continue;\n                if(graph[i][j] == 1){\n                    adj[i].push_back(j);\n                    adj[j].push_back(i);\n                }\n            }\n        }\n\n        int res = -1, resVal = INT_MAX;\n\n        for(int i=0;i<initial.size();i++){\n            int val = getInfected(adj, initial, initial[i], n);\n            if(val < resVal){\n                resVal = val;\n                res = initial[i];\n            }\n        }\n\n        return res;\n    }\n};\n```
['C++']