Easy C++ Code.
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;

class Solution {
private:
    int find(int node, vector<vector<int>>& adj, vector<int>& vals, int k) {
        if (k == 0) return vals[node]; 

        vector<int> neighbors;
        for (int neighbor : adj[node]) {
            neighbors.push_back(vals[neighbor]);
        }
        sort(neighbors.rbegin(), neighbors.rend());

        int sum = vals[node]; 
        for (int i = 0; i < min(k, (int)neighbors.size()); i++) {
            if (neighbors[i] > 0) 
                sum += neighbors[i];
        }

        return sum;
    }

public:
    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {
        int n = vals.size();
        vector<vector<int>> adj(n);
        for (auto& edge : edges) {
            int u = edge[0], v = edge[1];
            adj[u].push_back(v);
            adj[v].push_back(u);
        }

        int ans = INT_MIN;
        for (int i = 0; i < n; i++) {
            int res = find(i, adj, vals, k);
            ans = max(ans, res);
        }

        return ans;
    }
};

```
['C++']