Python Max Heap Simple Solution without Sorting
Complexity\n- Time complexity: O(k * logn)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n    def maxSubsequence(self, nums: List[int], k: int) -> Li
# Complexity\n- Time complexity: $$O(k * logn)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution:\n    def maxSubsequence(self, nums: List[int], k: int) -> List[int]:\n        res = [""] * len(nums)\n        nums = [(-n, i) for i, n in enumerate(nums)]\n        heapq.heapify(nums)\n        while k:\n            val, i = heapq.heappop(nums)\n            res[i] = -val\n            k -= 1\n        res = [val for val in res if val != ""]\n        return res\n```
['Heap (Priority Queue)', 'Python3']