Java, PriorityQueue
\n\tpublic int[] maxSubsequence(int[] nums, int k) {\n\t\tif (nums.length == 1)\n\t\t\treturn nums;\n\n\t\tint max = Integer.MIN_VALUE;\n\t\tint sum = 0;\n\t\ti
```\n\tpublic int[] maxSubsequence(int[] nums, int k) {\n\t\tif (nums.length == 1)\n\t\t\treturn nums;\n\n\t\tint max = Integer.MIN_VALUE;\n\t\tint sum = 0;\n\t\tint index = 0;\n\t\t\n\t\tQueue<int[]> q = new PriorityQueue<>((a,b)-> b[0]-a[0]);\n\n\t\tfor (int i = 0; i < nums.length; i++) {\n\t\t\tq.add(new int[] {nums[i], i});\t// saves index in order to sort k-biggest elements\n\t\t}\n\t\t\n\t\tint[][] res = new int[k][2];\n\t\tint i = 0;\n\t\tint kk = k;\n\t\twhile (kk > 0) {\n\t\t\tres[i] = q.poll();\n\t\t\ti++;\n\t\t\tkk--;\n\t\t}\n\t\t\n\t\tArrays.sort(res, (a,b)->a[1]-b[1]);\n\t\t\n\t\tint[] result = new int[k];\n\t\t\n\t\tfor (i = 0; i < k; i++) {\n\t\t\tresult[i] = res[i][0];\n\t\t}\n\n\t\treturn result;\n\t}\n```
['Heap (Priority Queue)', 'Java']