✅BFS + BitMagic || python
Code
\n# Code\n```python3 []\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        n=len(values)\n        gra=[[] for i in range(n)]\n        for a,b,time in edges:\n            gra[a].append([b,time])\n            gra[b].append([a,time])\n\n        q=deque()\n        q.append([0,0,1,values[0]])\n        ans=0\n        while(len(q)):\n            t,i,s,val=q.popleft()\n            # if(t>maxTime):continue\n            if(i==0):\n                ans=max(ans,val)\n            for a,b in gra[i]:\n                if(t+b<=maxTime):\n                    if(s&(1<<a)):\n                        q.append([t+b,a,s,val])\n                    else:\n                        q.append([t+b,a,s|(1<<a),val+values[a]])\n\n        return ans\n            \n```
['Array', 'Graph', 'Python3']