Schedule Queued Builds With Team Concurrency Limits and Production Priority
Last updated: November 29, 2026
Quick Overview
Simulate a build farm with a fixed number of global build slots where each team may run at most K builds at once; whenever a slot is free, start the best eligible build (production before preview, then earliest submitted, then by id) and return each build's start time.
Vercel
November 29, 20260
0
0 solved
Simulate a build farm with a fixed number of global build slots where each team may run at most K builds at once; whenever a slot is free, start the best eligible build (production before preview, then earliest submitted, then by id) and return each build's start time.
Every git push to a Vercel project triggers a build, and plans cap concurrent builds per team while production deploys should not sit behind a pile of preview builds. The onsite problem tests event-driven simulation, heaps and correctly handling the case where the globally best build is blocked by its team's limit.
What the Interviewer Expects
- Process events in time order: completions free slots before arrivals at the same timestamp are dispatched
- Keep per-team priority queues so a blocked team does not block others
- Choose the best eligible build across teams, not just the global head
- Advance time to the next arrival or completion to avoid idle loops
- Analyze complexity and propose an O(log T) team selection structure
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 prevent a team with constant production deploys from starving its own previews?
- How would you add weighted fair sharing between Hobby, Pro and Enterprise teams?
- Builds can be cancelled when a newer commit lands on the same branch. How does that change the design?
- How would this run as a distributed scheduler instead of a single loop?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Builds are (id, team, submit_time, duration, is_production). There are slots global runners and each team may have at most team_limit running. At any moment with a free slot, the scheduler start...
High-Level Design
A single global heap fails: its head may belong to a capped team, and popping past it means re-pushing blocked items repeatedly. Instead keep a heap per team ordered by (priority, submit, id), a...