js + bfs solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {number[][]} graph\n * @param {number[]} initial\n * @return {number}\n */\nvar minMalwareSpread = function (graph, initial) {\n    const bfs = (graph, initialInfected, ignored) => {\n        let queue = [...initialInfected]\n        let infected = new Set(initialInfected)\n\n        while (queue.length > 0) {\n            let node = queue.shift()\n            if (node === ignored) continue\n            for (let neighbor = 0; neighbor < graph.length; neighbor++) {\n                if (graph[node][neighbor] === 1 && !infected.has(neighbor) && neighbor !== ignored) {\n                    queue.push(neighbor)\n                    infected.add(neighbor)\n                }\n            }\n        }\n\n        return infected\n    };\n\n    let minInfectedCount = Infinity\n    let bestNode = null\n\n    for (let node of initial) {\n        let updatedInitial = new Set(initial)\n        updatedInitial.delete(node)\n\n        let infectedNodes = bfs(graph, updatedInitial, node)\n\n        if (infectedNodes.size < minInfectedCount ||\n            (infectedNodes.size === minInfectedCount && node < bestNode)) {\n            minInfectedCount = infectedNodes.size\n            bestNode = node\n        }\n    }\n\n    return bestNode\n};\n```
['JavaScript']