FASTEST SIMPLE PYTHON SOLUTION || DFS TRAVERSAL
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:$$O(V+2E)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(V+E)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def dfs(self,node,grid,hasApple,visited):\n        visited[node]=1\n        ct=0\n        for i in grid[node]:\n            if visited[i]==1:\n                continue\n            x=self.dfs(i,grid,hasApple,visited)\n            if x!=-1:\n                ct+=x\n                ct+=2\n        if ct>0 or hasApple[node]==True:\n            return ct\n        return -1\n\n\n\n    def minTime(self, n: int, edges: List[List[int]], hasApple: List[bool]) -> int:\n        grid=[[] for i in range(n)]\n        for i, j in edges:\n            grid[i].append(j)\n            grid[j].append(i)\n        visited=[0]*n\n        x=self.dfs(0,grid,hasApple,visited)\n        if x==-1:\n            return 0\n        return x\n\n```
['Python3']