python dfs 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```\nclass Solution:\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        # brute force\n\n        def dfs(graph: List[List[int]], initial: Set[int], infected_by: List[List[int]], initial_infected: int, current: int, visited: Set[int]) -> None:\n            if current in visited:\n                return\n\n            if current in initial and current != initial_infected:\n                return\n\n            visited.add(current)\n            if current != initial_infected:\n                infected_by[current].append(initial_infected)\n\n            for neighbor in range(len(graph[current])):\n                if graph[current][neighbor] == 1 and current != neighbor:\n                    dfs(graph, initial, infected_by, initial_infected, neighbor, visited)\n\n\n        initial = sorted(initial)\n        initial_set = set(initial)\n        n = len(graph)\n        infected_by = [[] for _ in range(n)]\n        for v in initial:\n            visited = set()\n            dfs(graph, initial_set, infected_by, v, v, visited)\n\n        rst = [0 for _ in range(n)]\n        for v in range(len(infected_by)):\n            if len(infected_by[v]) == 1:\n                rst[infected_by[v][0]] += 1\n\n        max_uniquely_infected = 0\n        rst_index = initial[0]\n        for v in initial:\n            if rst[v] > max_uniquely_infected:\n                rst_index = v\n                max_uniquely_infected = rst[v]\n\n        return rst_index\n\n\n\n\n        \n```
['Python3']