You are given an integer array nums of length n and an integer k.
The value of a subarray is defined as the difference between the maximum element and the minimum element in that subarray.
You need to select k subarrays from nums. You are allowed to choose the same subarray multiple times.
Return the maximum possible total sum of the values of the chosen k subarrays.
Constraints:
nums.length
nums[i]
k
You are given an integer array nums of length n and an integer k.
The value of a subarray is defined as the difference between the maximum element and the minimum element in that subarray.
You need to select k subarrays from nums. You are allowed to choose the same subarray multiple times.
Return the maximum possible total sum of the values of the chosen k subarrays.
Constraints:
nums.length
nums[i]
k