You are given an integer array nums and two integers length and k.
You may perform at most k swap operations on nums.
In one swap operation, you may choose two distinct indices i and j and swap nums[i] and nums[j].
Return the maximum possible sum of a subarray of length exactly length after performing the swaps.
Example 1:
Input: nums = [1,-1,0,2], length = 2, k = 1
Output: 3
Explanation:
[1, 2, 0, -1].[1, 2] has length 2 and sum 3.Example 2:
Input: nums = [4,3,2,4], length = 3, k = 2
Output: 11
Explanation:
[4, 3, 4, 2].[4, 3, 4] has length 3 and sum 11.Example 3:
Input: nums = [-1,-2], length = 2, k = 0
Output: -3
Explanation:
No swaps are allowed. The only subarray of length 2 is [-1, -2], whose sum is -3.
Constraints:
1 <= nums.length <= 300-109 <= nums[i] <= 1091 <= length <= nums.length0 <= k <= nums.lengthNo sample inputs for this problem yet. The examples in the statement show the format.