Daily challenge for 2026-10-12
650. Minimum Cost Parcel Batching
You are given a list of parcel measurements, a maximum batch length k, and a setup_fee. You must partition the parcels into contiguous, non-empty batches such that each batch contains at most k parcels. The cost of a batch is the setup_fee plus the square of the difference between the maximum and minimum measurements in that batch. Return the minimum total cost to batch all parcels. If there are no parcels, the cost is 0.
Constraints:
There are 0–200 parcels; measurements are integers from 0 to 10,000. The batch limit k is from 1 to 200 and may exceed the number of parcels. The setup fee is a non-negative integer at most 1,000,000.
Example:
Input: measurements = [10, 2, 8, 3, 7], k = 3, setup_fee = 4
Output: 20
Run this challenge interactively in Python or JavaScript when the app loads.