[Python3] - Easy/Intuitive O(n*k)
The idea is to hold maximum k elements in order. Therefore we start with an empty array and follow the steps:\n1- Put nums[0] to the array since we know that le
The idea is to hold maximum **k** elements in order. Therefore we start with an empty array and follow the steps:\n1- Put `nums[0]` to the array since we know that `len(nums) >= 1`\n2- Until `max_k` reaches **k** elements, put each element to the array (optimized version: initialize it with first **k** elements of the input)\n3- When the `max_k` reaches the size of **k**, check if the `i th` element is larger than the minimum of the array, if so remove minumum and put the element at the end.\n\nTherefore, the order in the array will stay the same as the input.\n\n```python\nclass Solution:\n    def maxSubsequence(self, nums: List[int], k: int) -> List[int]:\n        max_k = [nums[0]]\n        for i in range(1, len(nums)):\n            if len(max_k) < k: max_k.append(nums[i])  # put first k elements \n            elif len(max_k) == k:  # whenever we have k elements\n                if nums[i] > min(max_k):  # if the i th element is bigger than the minimum of seen so far\n                    max_k.remove(min(max_k))  # remove minimum\n                    max_k.append(nums[i])  # append the current element at the end\n        return max_k\n```
[]