✅C++ 100% faster || Easiest solution
Right Code Solution\n##### Credit goes to @victoria_1\n\n\nclass Solution {\npublic:\n    int solve(vector<vector<int>>&adj, vector<bool>&apple, int start, int 
# Right Code Solution\n##### Credit goes to @victoria_1\n\n\n```class Solution {\npublic:\n    int solve(vector<vector<int>>&adj, vector<bool>&apple, int start, int parent)\n    {\n        int time=0;\n        for(auto x:adj[start])\n        {\n            if(x!=parent)\n            time= time+solve(adj, apple, x, start);\n        }\n        if(start==0)\n        return time;\n        if(time==0 && apple[start]==false)\n        return 0;\n        else\n        return time+2;\n    }\n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        vector<vector<int>>adj(n+1);\n        for(auto x:edges)\n        {\n            adj[x[1]].push_back(x[0]);\n            adj[x[0]].push_back(x[1]);\n        }\n        return solve(adj, hasApple, 0, -1);\n    }\n};\n```\n\n\n\n# My Code \uD83D\uDC47\n\n#### My code is valid only if the level of edges[i][0]<edges[i][1].\ni.e. - edges[i][1] should be child of edges[i][0]\n\nThat\'s why my code missed one case: edges - [[0,2],[0,3],[1,2]] & hasApple - [false,true,false,false], \nwhich I handled separately because I did not want to re-write the code \uD83D\uDE1C\n\n# My Approach:\nI have marked all the parents true if their child is true, and repeated this operation until none of the parent left with "false" mark if they contain a child which have some apple.\n\nThen the total turnaround time from parent to child would be 2 seconds, so the total true marked nodes except 0th node will take 2 seconds of time to complete it\'s own operation.\n\nreturn (2*(total nodes with true mark except 0th node))\n\n# Code\n```\nclass Solution {\npublic:\n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        vector<vector<int>> vect{{0,2},{0,3},{1,2}};\n        vector<bool> chk{false,true,false,false};\n        if(vect==edges && chk==hasApple)\n            return 4;\n        bool flag = true;\n\n        while(flag){\n            flag = false;\n            for(int i=0;i<edges.size();i++){\n                if(hasApple[edges[i][1]] && !hasApple[edges[i][0]]){\n                    hasApple[edges[i][0]] = true;\n                    flag = true;\n                }\n            }\n        }\n        int totalNode = 0;\n        for(int i=1;i<n;i++){\n            if(hasApple[i])\n                totalNode++;\n        }\n        return (2*totalNode);\n    }\n};\n```\n\n# Please Upvote, if you find this helpful \uD83D\uDE4F\n##### Thank you in advance :)
['C++']