Solution Swift [beats 100%]
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    func minTime(_ n: Int, _ edges: [[Int]], _ hasApple: [Bool]) -> Int {\n        var adjacencyList: [[Int]] = Array(repeating: [], count: n)\n        \n        for edge in edges {\n            let currentNode = edge[0]\n            let neighbour = edge[1]\n            \n            adjacencyList[currentNode].append(neighbour)\n            adjacencyList[neighbour].append(currentNode)\n        }\n        \n        return dfs(adjacencyList, hasApple, 0, -1)\n    }\n    \n    private func dfs(_ adjacencyList: [[Int]], _ hasApple: [Bool], _ currentNode: Int, _ parentNode: Int) -> Int {\n        var time = 0\n        \n        for child in adjacencyList[currentNode] {\n            if child == parentNode { continue }\n            \n            let childTime = dfs(adjacencyList, hasApple, child, currentNode)\n            \n            if childTime != 0 || hasApple[child] {\n                time += 2 + childTime\n            }\n        }\n        return time\n    }\n}\n```
['Depth-First Search', 'Swift']