
nums 오름차 순 정렬k개의 고유한 요소 수집function maxKDistinct(nums: number[], k: number): number[] {
const sorted = nums.toSorted((a, b) => a - b)
const seen = new Set()
const distincts = []
while(distincts.length < k && sorted.length) {
const poped = sorted.pop()
if(seen.has(poped)) continue
seen.add(poped)
distincts.push(poped)
}
return distincts
};