DFS || CPP || Easy Understanding
```\nclass Solution {\npublic:\n    int dfs(int src,int total,vector>&edge,vector&vis,vector&hasApple){\n        \n        vis[src]=true;\n        int children=
```\nclass Solution {\npublic:\n    int dfs(int src,int total,vector<vector<int>>&edge,vector<int>&vis,vector<bool>&hasApple){\n        \n        vis[src]=true;\n        int children=0;\n        \n        for(auto ele:edge[src]){\n            if(!vis[ele])\n                children+=dfs(ele,2,edge,vis,hasApple);\n        }\n        \n        if(!children && !hasApple[src])return 0;\n        return children+total;\n    }\n    \n    \n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        \n        vector<vector<int>>edge(n);\n        \n        for(int i=0;i<edges.size();i++){\n            edge[edges[i][0]].push_back(edges[i][1]);\n            edge[edges[i][1]].push_back(edges[i][0]);\n        }\n        \n        vector<int>vis(n);\n        \n        return dfs(0,0,edge,vis,hasApple);\n    }\n};
['Depth-First Search', 'C++']