Python Min-Heap solution, O(NlogN + KlogK), commented
\nclass Solution:\n    def kSum(self, nums: List[int], k: int) -> int:\n        # subtract stores the sum which needs to be subtracted from the maximum sum\n   
```\nclass Solution:\n    def kSum(self, nums: List[int], k: int) -> int:\n        # subtract stores the sum which needs to be subtracted from the maximum sum\n        # ans stores all the largest sum in decreasing order\n        # Initialize heap (minheap) to store current least value which needs to be\n        # subtracted from maxsum and the index of nums we are currently at.\n        sz, maxSum, subtract, heap, ans = len(nums), 0, [], [], []\n        # find the maxsum and update nums so that all elements are positive\n        for i in range(sz):\n            if nums[i] >= 0:\n                maxSum += nums[i]\n            else:\n                nums[i] = abs(nums[i])\n        # sorting nums as per absolute values\n        nums.sort()\n        # start from index 0 with minimum value as nums[0]\n        heappush(heap, (nums[0], 0))\n        while heap and len(subtract) < k - 1:\n            # pop the value to be subtracted and the current index from the heap\n            valToSubtract, idx = heappop(heap)\n            # push this value to subtract array\n            subtract.append(valToSubtract)\n            if idx < sz - 1:\n                # considering nums[i] in the subsequence\n                heappush(heap, (valToSubtract + nums[idx + 1], idx + 1))\n                # not considering nums[i] in the subsequence\n                heappush(heap, (nums[idx + 1] + (valToSubtract - nums[idx]) , idx + 1))\n        ans.append(maxSum)\n        for valToSubtract in subtract:\n            ans.append(maxSum - valToSubtract)\n        # return Kth largest sum \n        return ans[k - 1]\n```
['Heap (Priority Queue)', 'Python']