Skip to content

Practice Minimum Cost to Divide Array Into Subarrays

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3500
LeetCode Problem

Minimum Cost to Divide Array Into Subarrays

Problem Statement

Partition nums into nonempty contiguous subarrays covering the whole array in order. The ith subarray, using 1-based subarray numbering and covering indices l through r, costs (sum of nums[0..r] + k * i) multiplied by the sum of cost[l..r]. Return the minimum total cost of any partition.

Source: Minimum Cost to Divide Array Into Subarrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,1,4], cost = [4,6,6], k = 1
Output
110

# Example 2

Input
nums = [4,8,5,1,14,2,2,12,1], cost = [7,2,8,4,2,2,1,1,2], k = 7
Output
985

Constraints

1 <= nums.length <= 1000
cost.length == nums.length
1 <= nums[i], cost[i] <= 1000
1 <= k <= 1000

Related LeetCode Problems

Practice more problems similar to Minimum Cost to Divide Array Into Subarrays.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.