#3691

Maximum Total Subarray Value II

international master · 2165 · lc hard +32 · 22% accepted · 80 likes · top 2%

Description

Given nums and integer k, choose exactly k distinct non-empty subarrays (no two with the same l and r). Each contributes max - min to the total. Return the maximum achievable total.

Code

1
2
3