Compute Minimum Days with Cooling Period
Problem Description
You are given an ordered list of products to manufacture and a non-negative integer space representing a cooling period.
Each day, you have two options:
- Produce the next product in the given order.
- Stay idle.
A crucial constraint is that if you produce product x on day d, you cannot produce product x again until at least space full days have passed. This means the earliest valid day to produce the same product x again is d + space + 1.
Your objective is to determine the minimum total number of days required to produce all products in the specified order.
Example
products = [1, 3, 1, 3, 2]space = 2
Output: 6
Explanation:
- Day 1: produce
1 - Day 2: produce
3 - Day 3: idle (cannot produce
1yet,3is not next) - Day 4: produce
1 - Day 5: produce
3 - Day 6: produce
2
Function Signature
def compute_minimum_days(products: List[int], space: int) -> int:
# Function body
AI interview prep
Core dilemma
Efficiently scheduling a sequence of tasks (product production) while minimizing total time, given a per-task cooldown period that might force idle days.
1 tradeoff and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Compute Minimum Days with Cooling Period
Problem Description
You are given an ordered list of products to manufacture and a non-negative integer space representing a cooling period.
Each day, you have two options:
- Produce the next product in the given order.
- Stay idle.
A crucial constraint is that if you produce product x on day d, you cannot produce product x again until at least space full days have passed. This means the earliest valid day to produce the same product x again is d + space + 1.
Your objective is to determine the minimum total number of days required to produce all products in the specified order.
Example
products = [1, 3, 1, 3, 2]space = 2
Output: 6
Explanation:
- Day 1: produce
1 - Day 2: produce
3 - Day 3: idle (cannot produce
1yet,3is not next) - Day 4: produce
1 - Day 5: produce
3 - Day 6: produce
2
Function Signature
def compute_minimum_days(products: List[int], space: int) -> int:
# Function body