[Python] Concise DFS
Python\npy\n    def maximalPathQuality(self, A, edges, maxTime):\n        G = collections.defaultdict(dict)\n        for i, j, t in edges:\n            G[i][j] 
**Python**\n```py\n    def maximalPathQuality(self, A, edges, maxTime):\n        G = collections.defaultdict(dict)\n        for i, j, t in edges:\n            G[i][j] = G[j][i] = t\n\n        def dfs(i, seen, time):\n            res = sum(A[j] for j in seen) if i == 0 else 0\n            for j in G[i]:\n                if time >= G[i][j]:\n                    res = max(res, dfs(j, seen | {j}, time - G[i][j]))\n            return res\n\n        return dfs(0, {0}, maxTime)\n```
[]