Java Simple Solution Using MaxHeap | Sorting
\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b) -> b[0] - a[0]);\n        
```\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b) -> b[0] - a[0]);\n        \n        for(int i=0; i<nums.length; i++)\n            pq.offer(new int[]{nums[i], i});\n        \n        List<int[]> l = new ArrayList<>();\n        \n        while(k-- != 0)\n            l.add(pq.poll());\n        \n        Collections.sort(l, (a,b) -> a[1] - b[1]);\n            \n        int[] res = new int[l.size()];\n        \n        int index = 0;\n        \n        for(int[] i: l)\n            res[index++] = i[0];\n        \n        return res;\n    }\n}\n```
['Sorting', 'Heap (Priority Queue)', 'Java']