Clear and Consice DFS
\nclass Solution {\npublic:\n    vector<int>adj[100001];\n    int dfs(int child,int par,vector<bool>& apple)\n    {\n        int ans=0;\n        for(auto i:adj[
```\nclass Solution {\npublic:\n    vector<int>adj[100001];\n    int dfs(int child,int par,vector<bool>& apple)\n    {\n        int ans=0;\n        for(auto i:adj[child])\n        {\n            if (i!=par)\n            {\n                int collect=dfs(i,child,apple);\n                if (collect>0 || apple[i])\n                    collect++;\n                ans+=collect;\n            }\n        }\n        return ans;\n    }\n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& apple) {\n        for(int i=0;i<n-1;i++)\n        {\n            adj[edges[i][0]].push_back(edges[i][1]);\n            adj[edges[i][1]].push_back(edges[i][0]);\n        }\n        return 2*dfs(0,-1,apple);\n    }\n};\n```
['Depth-First Search', 'C++']