easy and short  code using dfs
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```\ndef dfs(v,gp,parent,hasApple):\n    vt=0\n    for i in range(len(gp[v])):\n        if gp[v][i]!=parent:\n            t=dfs(gp[v][i],gp,v,hasApple)\n            if hasApple[gp[v][i]] or t>0:\n                vt+=2+t\n    return vt\nclass Solution:\n    def minTime(self, n: int, edges: List[List[int]], hasApple: List[bool]) -> int:\n        gp=[]\n        for i in range(n):\n            gp.append([])\n        for i in range(len(edges)):\n            gp[edges[i][0]].append(edges[i][1])\n            gp[edges[i][1]].append(edges[i][0])\n        return dfs(0,gp,None,hasApple)\n\n\n```
['Depth-First Search', 'Graph', 'Recursion', 'Python', 'Python3']