You are given an integer array counts and an integer k.
Perform the following step exactly k times:
i whose value counts[i] is the largest in the array (any index if several tie).counts[i] to a running total.counts[i] by 1.Return the running total after all k steps.
It is guaranteed that the sum of counts is strictly greater than k, so a positive value is always available to pick. The total does not depend on how ties are broken.
Input: counts = [2,1,1,3], k = 4
Output: 8
Explanation:
Step 1 picks 3 -> counts = [2,1,1,2]
Step 2 picks 2 -> counts = [1,1,1,2]
Step 3 picks 2 -> counts = [1,1,1,1]
Step 4 picks 1 -> counts = [0,1,1,1]
Total = 3 + 2 + 2 + 1 = 8.
Input: counts = [10,10,11], k = 3
Output: 31
Explanation: The picks are 11, 10, 10. Total = 31.
counts.length ≤105counts[i] ≤106sum(counts) >k