[Javascript] | explanation | Code commented | PriorityQueue | O(NlogN + klogk)
Explanation in comment,\nhope it makes sense\n\n```\n/*\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n /\nvar kSum = function(nums, k) 
Explanation in comment,\nhope it makes sense\n\n```\n/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar kSum = function(nums, k) {\n    let pq = new MaxPriorityQueue(), sum = 0, n = nums.length;\n    \n    //sort numbers in ascending order with absolute value\n    nums.sort((a,b) => Math.abs(a) - Math.abs(b));\n    \n    //calculate sum of positive integers\n    for(let i = 0 ; i < n ; i++){\n        if(nums[i] > 0) sum += nums[i];\n    }\n    \n    //we have the biggest possible sum , now we just substract abs values of nums to get smaller ones\n    //this satisfies because\n    //for positive numbers we are removing them from subsequence and getting smaller sum\n    //for negetive numbers we are adding them to subsequence and getting smaller sum\n\n    //to get all possible combinations in decreasing order we will start from zero index,\n    //for current index we will subtract abs(nums[index]) from the current sum\n    //and we will subtract abs(nums[index]) and add(nums[index-1]) from the current sum    \n    //because we know the previous number was not in the current sum \n    //as we subtracting the current sum every time we increasing index\n    \n    //we go like this untill we get the kth sum\n    \n    pq.enqueue(0, sum);\n    let q;\n    while(k--){\n        q = pq.dequeue();\n        if(q.element < n){\n            pq.enqueue(q.element+1, q.priority - Math.abs(nums[q.element]));\n            if(q.element>0) pq.enqueue(q.element+1, q.priority + Math.abs(nums[q.element-1]) - Math.abs(nums[q.element]));\n        }\n    }\n    return q.priority;\n};
['JavaScript']