Tap here to switch tabs
Problem
Submissions

Problem: Sum of K Subarrays With Length at Least M

med
30 min
Try to solve the Sum of K Subarrays With Length at Least M problem.

Statement

You are given an integer array nums and two integers k and m.

Find the maximum possible sum of k disjoint subarrays of nums such that each chosen subarray has a length of at least m.

Return this maximum sum.

Constraints:

  • 1≤1 \leq nums.length ≤2000\leq 2000

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

  • 1≤1 \leq k ≤⌊\leq \lfloornums.length // m⌋\rfloor

  • 1≤1 \leq m ≤3\leq 3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of K Subarrays With Length at Least M

med
30 min
Try to solve the Sum of K Subarrays With Length at Least M problem.

Statement

You are given an integer array nums and two integers k and m.

Find the maximum possible sum of k disjoint subarrays of nums such that each chosen subarray has a length of at least m.

Return this maximum sum.

Constraints:

  • 1≤1 \leq nums.length ≤2000\leq 2000

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

  • 1≤1 \leq k ≤⌊\leq \lfloornums.length // m⌋\rfloor

  • 1≤1 \leq m ≤3\leq 3