Simple Sorting || C++ ||✅✅ Fast
\nbool comparator(int a,int b)\n{\n    return a>b;\n}\nclass Solution {\npublic:\n   \n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) 
```\nbool comparator(int a,int b)\n{\n    return a>b;\n}\nclass Solution {\npublic:\n   \n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        int n=vals.size();\n        vector<vector<int>>dp(n);\n        for(int i=0;i<edges.size();i++) \n        {\n            dp[edges[i][0]].push_back(vals[edges[i][1]]);\n            dp[edges[i][1]].push_back(vals[edges[i][0]]);\n        }\n        int res = INT_MIN;\n        for(int i=0 ; i<n ;i++) \n        {\n            sort(dp[i].begin(),dp[i].end(),comparator);\n        }\n        for(int i=0 ; i<dp.size() ;i++) \n        {\n            \n            int count=vals[i];\n            res = max(res,count);\n            for(int j=0 ; j<min(k,(int)dp[i].size()) ; j++) {\n                count+=dp[i][j];\n                res = max(res,count);\n            }\n        }\n        return res;\n        \n    }\n};\n```
['C']