#3689

Maximum Total Subarray Value I

specialist · 665 · lc medium +30 · 64.3% accepted · 53 likes · top 68%

Description

Given nums and integer k, pick exactly k non-empty subarrays (repetitions allowed). Each subarray contributes max - min to the total. Return the maximum achievable total.

Code

1
2
3