TS Code
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```\nfunction minMalwareSpread(graph: number[][], initial: number[]): number {\n    const n = graph.length;\n    const infected = new Array(n).fill(false);\n    function dfs(graph: number[][], u: number, visited: boolean[], infected: boolean[]): number {\n        if (infected[u]) return 0;\n        visited[u] = true;\n        let count = 1;\n        for (let v = 0; v < graph[u].length; v++) {\n            if (!visited[v] && graph[u][v] === 1) {\n                const c = dfs(graph, v, visited, infected);\n                if (c === 0) {\n                    infected[u] = true;\n                    return 0;\n                }\n                count += c;\n            }\n        }\n        return count;\n    }\n    \n    for (const u of initial) {\n        infected[u] = true;\n    }\n    let ans = initial[0], max = 0;\n    for (const u of initial) {\n        const visited = new Array(n).fill(false);\n        visited[u] = true;\n        let count = 0;\n        for (let i = 0; i < n; i++) {\n            if (!visited[i] && graph[u][i] === 1) {\n                count += dfs(graph, i, visited, infected);\n            }\n        }\n        if (count > max || count === max && u < ans) {\n            max = count;\n            ans = u;\n        }\n    }\n    return ans;\n}\n```
['TypeScript', 'JavaScript']