Assign Repair Orders to Service Bays in Arrival Order

Last updated: November 29, 2026

Quick Overview

Given repair jobs with an arrival time and duration and k service bays, assign each job in arrival order to the lowest-numbered free bay, or, if all bays are busy, to the bay that frees up first, and return each job's bay, start and end time.

Tekion
Coding & Algorithms
Software Engineer
Tekion
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Medium

0

0

0 solved


Given repair jobs with an arrival time and duration and k service bays, assign each job in arrival order to the lowest-numbered free bay, or, if all bays are busy, to the bay that frees up first, and return each job's bay, start and end time.

Tekion's service products cover appointment scheduling, check-in and technician dispatch, so a simplified bay-assignment simulation is a natural way to test priority queues on a domain the company knows well. Graders look for a correct two-heap simulation, careful tie-breaking, and an honest complexity analysis.

What the Interviewer Expects
  • Clarifies tie-breaking: same arrival time, same finish time, and which bay wins
  • Sorts jobs by arrival and preserves FIFO for waiting jobs
  • Uses a heap of free bay ids and a heap of (end_time, bay) for busy bays
  • Releases all bays finished at or before the current arrival before choosing
  • States O(n log n + n log k) time
Key Topics to Cover
Heaps
Event simulation
Scheduling
Tie-breaking
Greedy
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you add technician skills so only certain bays can take an EV or a transmission job?
  • What changes if a waiting customer can be promoted ahead (for example a recall or a waiter appointment)?
  • How would you report the average wait time per bay and per hour of day?
  • How would you handle a job whose duration is only an estimate and runs over?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs: list of (job_id, arrival, duration) and k bays. Jobs are served first come, first served. When a job arrives and some bays are free, it takes the lowest-numbered free bay. If none are free...

High-Level Design

Keep two min-heaps. free holds idle bay ids. busy holds (end_time, bay). For each job in arrival order, pop every busy bay whose end time is at or before the arrival into free. Then either tak...


Submit Your Answer
Markdown supported

Related Questions