Java | max Heap | 100% faster | with explanation
\n### Intuitively thinking\n1. The largest sum of the array is the sum of all positive numbers.\n2. The sum of any subsequences is equivalent to the substractin
\n### Intuitively thinking\n1. The largest ***sum*** of the array is the sum of all positive numbers.\n2. The sum of any subsequences is **equivalent** to the **substracting** some positive numbers and **adding** some negative numbers from the sum.\n3. The second largest sum of the array is the **[sum - the minimum number in the absolute values array]**\n\n### Implementation\n1. We traversal this array. For one number in the array, we sum it if it\'s a positive number; we change it into positive if it\'s negative. We get the sum of all positive numbers and an array with absolute values\n2. Sort the array.\n3. Use max heap to maintain the max sum of subsequences.\n\n```\nclass Solution {\n    public long kSum(int[] nums, int k) {\n        long sum=0L;\n        for (int i = 0; i < nums.length; i++) {\n            if (nums[i]>0)  sum+=nums[i];\n            else    nums[i]=-nums[i];\n        }\n        Arrays.sort(nums);\n        PriorityQueue<Pair<Long,Integer>> pq=new PriorityQueue<>((a,b)->Long.compare(b.getKey(),a.getKey()));\n        pq.offer(new Pair<>(sum,0));\n        while(k-->1){\n            Pair<Long, Integer> top = pq.poll();\n            long s=top.getKey();\n            int i=top.getValue();\n            if(i<nums.length){\n                pq.offer(new Pair<>(s-nums[i],i+1));\n                if(i>0) pq.offer(new Pair<>(s-nums[i]+nums[i-1],i+1));\n            }\n        }\n        return pq.peek().getKey();\n    }\n}\n```
['Heap (Priority Queue)', 'Java']