
nums를 인덱스를 포함한 배열로 변환k개의 수만 따로 정의function maxSubsequence(nums: number[], k: number): number[] {
const valueWithIdx = nums.map((num, i) => [num, i])
const sorted = valueWithIdx.toSorted((a, b) => b[0] - a[0])
const maxSubSeq = []
for(let i = 0; i < k; i++) {
maxSubSeq.push(sorted[i])
}
const maxSubSeqSorted = maxSubSeq.toSorted((a, b) => a[1] - b[1])
return maxSubSeqSorted.map(a => a[0])
};