Find the Minimum Robot Count That Meets a Queue SLA

Last updated: November 29, 2026

Quick Overview

Queue items arrive at known times with known processing durations, and robots take items in FIFO order, each item going to whichever robot frees up first. Find the smallest number of robots such that every item completes within an SLA of its arrival, or return -1 if no count works.

UiPath
Coding & Algorithms
Software Engineer
UiPath
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Queue items arrive at known times with known processing durations, and robots take items in FIFO order, each item going to whichever robot frees up first. Find the smallest number of robots such that every item completes within an SLA of its arrival, or return -1 if no count works.

Orchestrator queues carry SLA settings and customers constantly ask how many unattended robots (and licenses) a process needs. This round checks whether a candidate can simulate a multi-server queue efficiently, spot the monotonic structure, and argue why binary search is valid rather than assuming it.

What the Interviewer Expects
  • Models the dispatch policy precisely before optimizing
  • Simulates k robots with a min-heap of free times
  • Identifies the impossible case (an item longer than the SLA)
  • Argues monotonicity: more robots never delays any item under FIFO earliest-free dispatch
  • Binary searches k over [1, n] and states the bounds
  • Validates against a brute-force linear scan
Key Topics to Cover
Binary search on answer
Heaps
Queue simulation
Monotonicity
Capacity planning
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
  • Items have priorities (High, Normal, Low) like queue item priority. Does monotonicity still hold?
  • Robots have working hours (maintenance windows). How would the simulation change?
  • Durations are uncertain, given as distributions. How would you estimate the count that meets the SLA 95 percent of the time?
  • How would you return the schedule that proves your answer?
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

Input: list of (arrival, duration) and sla. Items are served strictly in arrival order; item i starts at max(arrival_i, earliest robot free time). An item meets the SLA if `finish - arrival <= s...

High-Level Design

Feasibility check for a fixed k: a min-heap of k robot free times; pop the earliest, schedule, push the finish. Monotonicity: with k+1 robots, by induction on items, the sorted vector of free ...


Submit Your Answer
Markdown supported

Related Questions