3263. Divide an Array Into Subarrays With Minimum Cost I
My accepted Python solution to LeetCode problem 3263, Divide an Array Into Subarrays With Minimum Cost I, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.1MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.1MB, accepted 2026-01-02.
class Solution:
def minimumCost(self, nums: List[int]) -> int:
# First subarray must start with nums[0]
# Need to find 2 smallest elements from nums[1:] for the other 2 subarrays
first = nums[0]
rest = sorted(nums[1:])
return first + rest[0] + rest[1]