Beats 100% ----> Simple Approach
Intuition\nThe task requires calculating the maximum star sum for each node in the graph, where the star of a node is the node itself and up to k of its neighbo
### Intuition\nThe task requires calculating the maximum star sum for each node in the graph, where the star of a node is the node itself and up to `k` of its neighboring nodes with the highest values. The goal is to find a way to maximize the sum by carefully selecting the `k` most beneficial neighboring values for each node.\n\n### Approach\n1. **Graph Representation**: First, represent the graph as an adjacency list. Each node will store the values of its neighboring nodes, rather than their indices, to allow easier summing of node values.\n  \n2. **Priority Queue for Top Values**: For each node, create a max-heap (priority queue) of its neighboring node values. This allows efficient retrieval of the `k` largest values from its neighbors.\n\n3. **Calculate the Star Sum**: For each node:\n   - Initialize the star sum with the node\u2019s own value.\n   - Add up to `k` highest values from its neighbors (from the priority queue), skipping values if they would reduce the sum (such as negative values or values that don\u2019t improve the total sum).\n   - Track the maximum star sum across all nodes.\n\n4. **Result**: Return the maximum star sum obtained.\n\n### Complexity\n- **Time Complexity**: \\(O(E + V \\log V)\\)\n  - Constructing the adjacency list takes \\(O(E)\\), where \\(E\\) is the number of edges.\n  - For each node, building the priority queue and retrieving the top `k` elements takes \\(O(V \\log V)\\).\n\n- **Space Complexity**: \\(O(V + E)\\)\n  - The adjacency list requires \\(O(V + E)\\) space.\n\n### Code\n\n```cpp\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        vector<vector<int>> adj(vals.size());\n        for (auto i : edges) {\n            adj[i[0]].push_back(vals[i[1]]);\n            adj[i[1]].push_back(vals[i[0]]);\n        }\n\n        int ans = INT_MIN;\n\n        for (int i = 0; i < vals.size(); i++) {\n            int a = k;\n            int b = vals[i];\n            priority_queue<int> pq(adj[i].begin(), adj[i].end());\n            while (a && !pq.empty()) {\n                if (b > pq.top() && pq.top() < 0) break;\n                b += pq.top();\n                pq.pop();\n                a--;\n            }\n            ans = max(ans, b);\n        }\n        return ans;\n    }\n};\n```
['C++']