You are given an integer array gifts representing the number of gifts in various piles, and an integer k representing the number of operations to perform.
In each operation, you must:
Select the pile containing the maximum number of gifts. If there are multiple piles with the maximum value, you may choose any of them.
Replace the number of gifts in the selected pile with
Return the total number of gifts remaining across all piles after performing this operation k times.
Constraints:
gifts.length
gifts[i]
k
You are given an integer array gifts representing the number of gifts in various piles, and an integer k representing the number of operations to perform.
In each operation, you must:
Select the pile containing the maximum number of gifts. If there are multiple piles with the maximum value, you may choose any of them.
Replace the number of gifts in the selected pile with
Return the total number of gifts remaining across all piles after performing this operation k times.
Constraints:
gifts.length
gifts[i]
k