2026-02-01 16:46:21 +0000 UTC
Divide an Array Into Subarrays With Minimum Cost I
Links
Code
class Solution:
def minimumCost(self, nums: List[int]) -> int:
num1, num2 = float("inf"), float("inf")
heap = []
for i in range(1, len(nums)):
heapq.heappush(heap, nums[i])
return nums[0] + heapq.heappop(heap) + heapq.heappop(heap)