[Python3] priority queue
Please pull this commit for solutions of weekly 307. \n\nIntuition\nHere, I will discuss a strategy to find the kth largest subsequence sum. \n We start from th
Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/b7391a11acc4e9dbe563ebef84f8d78f7943a0f7) for solutions of weekly 307. \n\n**Intuition**\nHere, I will discuss a strategy to find the kth largest subsequence sum. \n* We start from the sum of all positive numbers in `nums` which is the largest one (say `m`); \n* To proceed, we subtract absolute values from `m`; \n\t* If the number is positive, this is equivalent to removing the number from the subsequence sum; \n\t* If the number is negative, this is equivalent to adding the number to the subsequence sum;  \n* To enumerate all possitibilites, we generate a tree-ish path to cover different combinations;\n\t* This can be done by repeatedly generating two branches at each point with one always include a value at a given index `i` and the other always exclude the value. \n\nHere, I use a priority queue to control for the size so that the runtime won\'t explode. \n\n**Analysis**\nTime complexity O(NlogN + KlogK)\nSpace complexity O(N + K)\n\n```\nclass Solution:\n    def kSum(self, nums: List[int], k: int) -> int:\n        m = sum(x for x in nums if x > 0)\n        pq = [(-m, 0)] \n        vals = sorted(abs(x) for x in nums)\n        for _ in range(k): \n            x, i = heappop(pq)\n            if i < len(vals): \n                heappush(pq, (x+vals[i], i+1))\n                if i: heappush(pq, (x-vals[i-1]+vals[i], i+1))\n        return -x\n```
['Python3']