Solution Minimize Malware Spread II
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```\nclass Solution {\n    public $vis = array();\n\n    function dfs($v, $node, $nhi_dekhna, &$ans) {\n        $this->vis[$node] = true;\n        $ans++;\n        foreach ($v[$node] as $x) {\n            if (!$this->vis[$x] && $x != $nhi_dekhna) {\n                $this->dfs($v, $x, $nhi_dekhna, $ans);\n            }\n        }\n    }\n\n    function minMalwareSpread($graph, $initial) {\n        $n = count($graph);\n        $v = array_fill(0, $n, array());\n        \n        for ($i = 0; $i < $n; $i++) {\n            for ($j = 0; $j < $n; $j++) {\n                if ($graph[$i][$j] == 1 && $i != $j) {\n                    $v[$i][] = $j;\n                }\n            }\n        }\n        \n        sort($initial);\n        $res = PHP_INT_MAX;\n        $res1 = $initial[0];\n        \n        foreach ($initial as $x) {\n            $ans = 0;\n            $this->vis = array_fill(0, $n, false);\n            foreach ($initial as $y) {\n                if ($x != $y && !$this->vis[$y]) {\n                    $this->dfs($v, $y, $x, $ans);\n                }\n            }\n            if ($ans < $res) {\n                $res1 = $x;\n                $res = $ans;\n            }\n        }\n        \n        return $res1;\n    }\n}\n\n```
['PHP']