C++ || Sorting || HAshing || Easy Code
 # Intuition\n<!-- Describe your first thoughts on how to solve this problem.  \n\n\n\n\n\n\n\n\n\n -->\n\n# Code\n\nclass Solution {\npublic:\n    int maxStarS
<!-- # 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        if(k==0){\n            int maxi=INT_MIN;\n            for(int n:vals)maxi=max(maxi,n);\n            return maxi;\n        }\n        int n=vals.size();\n        map<int,vector<pair<int,int>> > adj;\n        for(auto p:edges){\n            adj[p[0]].push_back({vals[p[1]], p[1]});\n            adj[p[1]].push_back({vals[p[0]], p[0],});\n        }\n        int maxi=INT_MIN;\n        for(int i=0;i<n;i++){\n            sort(adj[i].rbegin(),adj[i].rend());\n            int kk=k;\n            int sum=vals[i];\n            maxi=max(maxi,sum);\n            for(auto p:adj[i]){\n                sum+=p.first;\n                kk--;\n                maxi=max(maxi,sum);\n                if(kk==0 || p.first<0)break;\n            }\n        }\n        return maxi;\n    }\n};\n```
['C++']