[C++|Java|Python3] sorting
Please pull this commit for solutions of biweekly 93. \n\nIntuition\nFor each node, we find the (at most) k largest adjacent nodes in vals. \n\nImplementation\n
Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/661cb4686dc915189ddbf0bc35fa51f408bf42ef) for solutions of biweekly 93. \n\n**Intuition**\nFor each node, we find the (at most) `k` largest adjacent nodes in `vals`. \n\n**Implementation**\n**C++**\n```\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        int n = vals.size(); \n        vector<vector<int>> graph(n); \n        for (auto& e : edges) {\n            graph[e[0]].push_back(e[1]); \n            graph[e[1]].push_back(e[0]); \n        }\n        int ans = INT_MIN; \n        for (int u = 0; u < n; ++u) {\n            int cand = vals[u]; \n            if (graph[u].size() > k) \n                nth_element(graph[u].begin(), graph[u].begin()+k, graph[u].end(), [&](auto& lhs, auto& rhs) {\n                    return vals[lhs] > vals[rhs]; \n                }); \n            for (int i = 0; i < k && i < graph[u].size(); ++i) \n                cand += max(0, vals[graph[u][i]]); \n            ans = max(ans, cand); \n        }\n        return ans; \n    }\n};\n```\n**Java**\n```\nclass Solution {\n    public int maxStarSum(int[] vals, int[][] edges, int k) {\n        int n = vals.length; \n        List<Integer>[] graph = new ArrayList[n]; \n        for (int u = 0; u < n; ++u) graph[u] = new ArrayList(); \n        for (int[] e : edges) {\n            graph[e[0]].add(e[1]); \n            graph[e[1]].add(e[0]); \n        }\n        int ans = Integer.MIN_VALUE; \n        for (int u = 0; u < n; ++u) {\n            int cand = vals[u]; \n            if (graph[u].size() > k) Collections.sort(graph[u], (a, b) -> vals[b] - vals[a]);\n            for (int v = 0; v < k && v < graph[u].size(); ++v)\n                cand += Math.max(0, vals[graph[u].get(v)]); \n            ans = Math.max(ans, cand); \n        }\n        return ans; \n    }\n}\n```\n**Python3**\n```\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        n = len(vals)\n        graph = [[] for _ in range(n)]\n        for u, v in edges: \n            graph[u].append(v)\n            graph[v].append(u)\n        ans = -inf \n        for i, u in enumerate(graph): \n            u.sort(key=vals.__getitem__, reverse=True)\n            cand = vals[i] + sum(max(0, vals[x]) for x in u[:k])\n            ans = max(ans, cand)\n        return ans \n```\n**Complexity**\nTime `O(ElogE)`\nSpace `O(E)`
['C', 'Java', 'Python3']