simple easy no need of priority queue space optmized
🌟 Maximize Star Sum – Elegant Graph Traversal! 🌟🧠 IntuitionThe problem boils down to maximizing the sum of a "star structure" centered at each node. This involv
# 🌟 Maximize Star Sum – Elegant Graph Traversal! 🌟  

### 🧠 Intuition  
The problem boils down to maximizing the sum of a "star structure" centered at each node. This involves choosing the highest values from its neighbors while adhering to the constraint of at most `k` neighbors. Sorting and pruning negative values ensure we maximize the sum effectively.

### 🛠️ Approach  
1. **Graph Representation**: Represent the graph using an adjacency list, where each node is linked to the values of its neighbors.  
2. **Neighbor Sorting**: For each node, sort its neighbors in descending order. This allows us to prioritize the top `k` values.  
3. **Star Sum Calculation**: Add the top `k` values (ignoring negatives) to the node's value to calculate its star sum. Track the maximum star sum across all nodes.  

### ⏳ Complexity  
- **Time Complexity**:  
  - Building the adjacency list: $$O(E)$$, where $$E$$ is the number of edges.  
  - Sorting neighbors: $$O(V \cdot \log(V))$$, where $$V$$ is the average degree of nodes.  
  Overall: $$O(E + V \cdot \log(V))$$.  

- **Space Complexity**:  
  - Adjacency list storage: $$O(E)$$.  

### 💻 Code  
```cpp
class Solution {
public:
    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {
        vector<int> adj[vals.size() + 1];
        for (int i = 0; i < edges.size(); i++) {
            adj[edges[i][0]].push_back(vals[edges[i][1]]);
            adj[edges[i][1]].push_back(vals[edges[i][0]]);
        }
        int ans = INT_MIN;
        for (int i = 0; i < vals.size(); i++) {
            int temp = vals[i];
            sort(adj[i].begin(), adj[i].end(), greater<int>());
            for (int j = 0; j < k && j < adj[i].size(); j++) {
                if (adj[i][j] < 0) break;
                temp += adj[i][j];
            }
            ans = max(ans, temp);
        }
        return ans;
    }
};
```  

Let me know your thoughts, and feel free to share your optimizations or alternate approaches! 🚀
['C++']