Simple java code 3 ms beats 98.35 %
\n# Complexity\n\n\n# Code\n\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        PriorityQueue<Integer> mins = new PriorityQueue<>(
\n# Complexity\n![image.png](https://assets.leetcode.com/users/images/1010f908-4f7d-4514-b4aa-78526fe4a555_1715090327.0616825.png)\n\n# Code\n```\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        PriorityQueue<Integer> mins = new PriorityQueue<>((i1, i2) -> nums[i1] - nums[i2]);\n        int[] tmp = new int[nums.length];\n        for (int i = 0; i < k; i++) {\n            mins.add(i);\n            tmp[i] = 1;\n        }\n        for (int i = k; i < nums.length; i++) {\n            int j = mins.peek();\n            if (nums[j] < nums[i]) {\n                mins.poll();\n                mins.add(i);\n                tmp[j] = 0;\n                tmp[i] = 1;\n            }\n        }\n        int[] result = new int[k];\n        for (int i = 0, j = 0; i < tmp.length; i++) {\n            if (tmp[i] == 1)    result[j++] = nums[i];\n        }\n        return result;\n    }\n}\n```
['Array', 'Heap (Priority Queue)', 'Java']