Simple n Slow
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# 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 max_sum_list(self, ls):\n        sum=0\n        for val in ls:\n            if val>0:\n                sum+=val\n        return sum \n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        max_star_sum=-inf\n        top_k_neighbours={}\n        if not edges and vals:\n            vals.sort()\n            return vals[-1]\n        if k>0:\n            for edge in edges:\n                for i in range(2):\n                    if vals[edge[(i+1)%2]]>0:\n                        if edge[i] in top_k_neighbours.keys():\n                            if len(top_k_neighbours[edge[i]])<k:\n                                top_k_neighbours[edge[i]].append(vals[edge[(i+1)%2]])\n                                top_k_neighbours[edge[i]].sort()\n                            elif vals[edge[(i+1)%2]]>top_k_neighbours[edge[i]][0]:\n                                top_k_neighbours[edge[i]]=top_k_neighbours[edge[i]][1:]\n                                top_k_neighbours[edge[i]].append(vals[edge[(i+1)%2]])\n                                top_k_neighbours[edge[i]].sort()\n                        else:\n                            top_k_neighbours[edge[i]]=[vals[edge[(i+1)%2]]]\n        for i in range(len(vals)):\n            neighbours_sum = sum(top_k_neighbours[i]) if i in top_k_neighbours.keys() else 0\n            node_sum=neighbours_sum+vals[i]\n            if node_sum>max_star_sum:\n                max_star_sum=node_sum\n        # print(top_k_neighbours)\n        return max_star_sum\n```
['Python3']