Python (Simple Backtracking)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def maximalPathQuality(self, values, edges, maxTime):\n        n, self.max_val, graph = len(values), 0, defaultdict(list)\n\n        for u,v,t in edges:\n            graph[u].append((v,t))\n            graph[v].append((u,t))\n\n        def backtrack(node,values,total,time):\n            if node == 0 and time <= maxTime:\n                self.max_val = max(self.max_val,total)\n\n            for neighbor,t in graph[node]:\n                if time + t <= maxTime:\n                    val = values[neighbor]\n                    values[neighbor] = 0 \n                    backtrack(neighbor,values,total+val,time+t)\n                    values[neighbor] = val\n\n        val = values[0]\n        values[0] = 0\n        backtrack(0,values,val,0)\n        return self.max_val\n```
['Python3']