✅Easy solution || ✅Short & Simple || ✅Best Method || ✅Easy-To-Understand
\n# Code\n\nclass Solution {\npublic:\n    vector<bool> vis;\n    int dfs(unordered_map<int, vector<int>> &graph,vector<bool>& hasApple,int node,int cost)\n    
\n# Code\n```\nclass Solution {\npublic:\n    vector<bool> vis;\n    int dfs(unordered_map<int, vector<int>> &graph,vector<bool>& hasApple,int node,int cost)\n    {\n        if(vis[node])\n        return 0;\n        vis[node]=true;\n        int children_cost=0;\n        for(auto x:graph[node])\n            children_cost+=dfs(graph,hasApple,x,2);\n        if(children_cost==0 && hasApple[node]==false)\n        return 0;\n        return children_cost+cost;\n    }\n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        unordered_map<int, vector<int>> graph;\n        vis=vector<bool>(n,false);\n        for(auto &x:edges)\n        {\n            graph[x[0]].push_back(x[1]);\n            graph[x[1]].push_back(x[0]);\n        }\n        return dfs(graph,hasApple,0,0);\n    }\n};\n```\nPlease **UPVOTE** if it helps \u2764\uFE0F\uD83D\uDE0A\nThank You and Happy To Help You!!
['C++']