You are given an integer array nums containing positive integers and an integer k.
Your task is to select at most k distinct elements from nums such that their sum is maximized.
After selecting, return the chosen elements in strictly descending order.
If there are multiple possible sets with the same maximum sum, any valid set is acceptable.
Input: nums = [12, 45, 32, 45, 50], k = 3
Output: [50, 45, 32]
Input: nums = [10, 10, 20, 5, 15], k = 2
Output: [20, 15]
Accepted:
Submission: