C++|Easy|Map|Sorting
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        int X = 1e5+10;\n        vector<int>adj[X];\n        for(auto x:edges)\n        {\n            int a = x[0];\n            int b = x[1];\n            adj[a].push_back(b);\n            adj[b].push_back(a);\n        }\n        map<int,vector<int>>mp;// Store the connected nodes of each index to calculate first k maximum values for each one\n        for(int i=0;i<vals.size();i++)\n        {\n            for(auto x:adj[i])\n            {\n                mp[i].push_back(vals[x]);\n            }\n        }\n        int ans = INT_MIN;\n        for(int i=0;i<vals.size();i++)\n        {\n            auto &x = mp[i];\n            sort(x.rbegin(),x.rend());// Sort and reverse the array\n            int sum = 0;\n            int maxi = 0;\n            for(int j=0;j<min(k,(int)x.size());j++)// Take the first maximum k elements\n            {\n                sum+=x[j];\n                maxi = max(maxi,sum);// In case the sum is negative or getting decreased then we will not consider those values like 5 4 3 -2 -1 then -2 and -1 will not be considered as they are decreasing the maximum sum\n            }\n            maxi+=vals[i];// Must add the value of the index because it is the center\n            ans = max(ans,maxi);\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'Sorting', 'C++']