ash
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```\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        vector<int> adj[vals.size()];\n        for(int i=0;i<edges.size();i++)\n        {\n            adj[edges[i][0]].push_back(edges[i][1]);\n            adj[edges[i][1]].push_back(edges[i][0]);\n        }\n        int max_starsum=INT_MIN;\n        for(int i=0;i<vals.size();i++)\n        {\n            priority_queue<int> pq;\n            int starsum=vals[i];\n            for(auto it:adj[i])\n            {\n                pq.push(vals[it]);\n            }\n            int j=k;\n            while(!pq.empty() and j>0)\n            {\n                int front = pq.top();\n                pq.pop();\n                if(starsum+front>starsum)starsum=starsum+front;\n                j--;\n            }\n            max_starsum=max(max_starsum,starsum);\n        }\n        return max_starsum;\n    }\n};\n```
['C++']