C++ (Simple DFS)
```\nclass Solution {\npublic:\n    \n    bool dfs(int idx , unordered_map>&mp , vector&hasApple , int &count , vector&visited)\n    {\n        visited[idx] = t
```\nclass Solution {\npublic:\n    \n    bool dfs(int idx , unordered_map<int , vector<int>>&mp , vector<bool>&hasApple , int &count , vector<bool>&visited)\n    {\n        visited[idx] = true ; \n        bool what = false ; \n        for(auto i : mp[idx])\n        {\n            if(visited[i]) continue ; \n            bool ans = dfs(i , mp , hasApple , count , visited) ; \n            if(ans) count+= 2 ; \n            what = what || ans ; \n        }\n        what = what || hasApple[idx] ; \n        return what ; \n    }\n    \n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        unordered_map<int , vector<int>> mp ; \n        for(auto i : edges)\n        {\n            mp[i[0]].push_back(i[1]) ; \n            mp[i[1]].push_back(i[0]) ; \n        }\n        int count = 0 ; \n        \n        vector<bool>visited(n , false) ; \n        visited[0] = true ; \n        for(int i = 0 ; i < mp[0].size() ; i++)\n        {\n            if(visited[mp[0][i]]) continue ; \n            bool ans = dfs(mp[0][i] , mp , hasApple , count , visited) ; \n            if(ans) count += 2 ; \n        }\n        return count ; \n    }\n};
['Tree', 'Breadth-First Search', 'Recursion']