Minimum Time Slots to Run Lambda Jobs With a Per-Type Cooldown
Last updated: November 29, 2026
Quick Overview
A worker runs one job per time slot. Jobs of the same type must be separated by at least n slots, and idle slots are allowed. Given a list of job types and n, return the minimum number of slots to finish all jobs.
Amazon
November 29, 20260
0
0 solved
A worker runs one job per time slot. Jobs of the same type must be separated by at least n slots, and idle slots are allowed. Given a list of job types and n, return the minimum number of slots to finish all jobs.
Amazon phone screens use this scheduling problem because it rewards seeing a closed-form count after a heap simulation. The framing is a rate-limited worker processing AWS Lambda-style jobs where each function type needs a cooldown.
What the Interviewer Expects
- Start with a max-heap plus cooldown queue simulation
- Derive the formula (max_count - 1) * (n + 1) + ties
- Take the max of the formula and the number of jobs
- Explain why the most frequent type dictates the frame
- Test with n = 0 and many types
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the actual schedule, including idle slots?
- What if jobs must run in their given order?
- How would you handle different cooldowns per job type?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of job type labels and integer n >= 0. Output: minimum slots, counting idle ones, such that any two jobs of the same type are at least n + 1 slots apart in start time....
High-Level Design
Let the most frequent type occur f times and let t be how many types share that count. Lay out f frames of width n + 1 headed by the top types; the last frame only needs t slots. That gives (f - 1) * ...