2656. Maximum Sum With Exactly K Elements
You are given a 0-indexed integer array
numsand an integerk. Your task is to perform the following operation exactlyktimes in order to maximize your score:
- Select an element
mfromnums.- Remove the selected element
mfrom the array.- Add a new element with a value of
m + 1to the array.- Increase your score by
m.Return the maximum score you can achieve after performing the operation exactly
ktimes.
1 | class Solution { |