✅ Simple Brute Force || C++
\n\n# Code\n\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n         int n=vals.size();\n        vector
\n\n# Code\n```\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n         int n=vals.size();\n        vector<int> adj[n];\n        for(auto& it:edges){\n            adj[it[0]].push_back(vals[it[1]]);\n            adj[it[1]].push_back(vals[it[0]]);\n\n        }\n        for(auto& it:adj){\n            sort(rbegin(it),rend(it));\n        }\n        \n        int ans=-1e9;\n        \n        for(int i=0;i<n;++i){\n           \n            int cnt=0;\n            cnt+=vals[i];\n            int ck=0;\n            for(auto& it:adj[i]){\n                \n                if(it>0){\n                     cnt+=it;\n                    ck++;\n                }\n                if(ck>=k){\n                    break;\n                }\n            }\n            ans=max(ans,cnt);\n        }\n         return ans;\n    }\n};\n```
['C++']