Skip to content

Practice Divide an Array Into Subarrays With Minimum Cost I

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

Easy#3010
LeetCode Problem

Divide an Array Into Subarrays With Minimum Cost I

Problem Statement

You are given an array of integers nums of length n. The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3. You need to divide nums into 3 disjoint contiguous subarrays. Return the minimum possible sum of the cost of these subarrays.

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

Examples

# Example 1

Input
nums = [1,2,3,12]
Output
6

# Example 2

Input
nums = [5,4,3]
Output
12

# Example 3

Input
nums = [10,3,1,1]
Output
12

Constraints

3 <= n <= 50
1 <= nums[i] <= 50

Related LeetCode Problems

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

Review your practice with PhantomCodeAI

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