[Java] greedy : sort + max heap
```\n public long kSum(int[] nums, int k) {\n        int len = nums.length;\n        long maxSum = 0;\n        for (int temp : nums) {\n            if (temp > 0
```\n public long kSum(int[] nums, int k) {\n        int len = nums.length;\n        long maxSum = 0;\n        for (int temp : nums) {\n            if (temp > 0) maxSum += temp;\n        }\n        if (k==1) return maxSum;\n\n        int[] absArray = IntStream.of(nums).map(Math::abs).sorted().toArray();\n\n        PriorityQueue<long[]> pq = new PriorityQueue<>(Comparator.comparingLong(e -> -e[0]));\n        List<Long> ans = new ArrayList<>();\n        ans.add((long) maxSum);\n\n        pq.add(new long[]{maxSum - absArray[0], 0});\n\n        while (ans.size() < k-1) {\n            long cur[] = pq.poll();\n            long curSum = cur[0];\n            long i = cur[1];\n            ans.add(curSum);\n\n            if (i + 1 < len) {\n                pq.add(new long[]{curSum + absArray[(int) i] - absArray[(int) i + 1], (int) i + 1});\n                pq.add(new long[]{curSum - absArray[(int) i + 1], i + 1});\n            }\n\n        }\n        long res = 0;\n        if (!pq.isEmpty()) res = pq.poll()[0];\n        return res;\n\n\n    }
['Java']