[C++] Simple Solution - O(n)
Find the apples from the end and check where you come from, then, let the start point of edge true(as an apple). Finally, count the number of edge you need to g
Find the apples from the end and check where you come from, then, let the start point of edge true(as an apple). Finally, count the number of edge you need to go through and it cost 2 seconds for each edge(back and forth).\n```\nclass Solution {\npublic:\n    int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {\n        int cnt = 0;\n        for(int i=edges.size()-1; i>=0; i--){\n            if(hasApple[edges[i][1]]){\n                cnt++;\n                hasApple[edges[i][0]] = true;\n            } \n        }\n        return cnt*2;\n    }\n};\n```\n\nthanks.
[]