✅adjacency list || sliding window || python
\n# Code\npython3 []\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        if(k==0):return max(vals)\n   
\n# Code\n```python3 []\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        if(k==0):return max(vals)\n        ans=max(vals)\n        n=len(vals)\n        graph=[[] for i in range(n)]\n        for e in edges:\n            graph[e[0]].append(vals[e[1]])\n            graph[e[1]].append(vals[e[0]])\n        for i in range(n):\n            graph[i].sort(reverse=True)\n            j=0\n            l=0\n            sumi=vals[i]\n            ans=max(ans,sumi)\n            while(l<len(graph[i]) and graph[i][l]>0):\n                sumi+=graph[i][l]\n                if(l-j+1>k):\n                    sumi-=graph[i][j]\n                    j+=1\n                ans=max(ans,sumi)\n                l+=1\n        return ans\n```
['Array', 'Greedy', 'Graph', 'Sorting', 'Python3']