Resolve Final Queue Item Status From Out of Order Robot Events

Last updated: November 29, 2026

Quick Overview

Given a list of (timestamp, item_id, event) robot events where event is Started, Failed or Succeeded, and a max retry count, compute each queue item's final status (Successful, Failed, Retrying or InProgress) plus a count per status. Events can arrive out of order and can be duplicated.

UiPath
Coding & Algorithms
Software Engineer
UiPath
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of (timestamp, item_id, event) robot events where event is Started, Failed or Succeeded, and a max retry count, compute each queue item's final status (Successful, Failed, Retrying or InProgress) plus a count per status. Events can arrive out of order and can be duplicated.

Orchestrator queues hand transactions to unattended robots and retry failed ones up to a configured limit, so a backend screen often starts with a small state machine over this kind of event log. The interviewer checks that you model states explicitly, treat terminal states as final, and handle messy input instead of trusting the happy path.

What the Interviewer Expects
  • Defines the status set and legal transitions before coding
  • Sorts events by timestamp with a deterministic tie-break
  • Ignores events after a terminal state and duplicates that do not match the current state
  • Counts failed attempts per item and compares against max retries correctly (retries, not attempts)
  • Returns both per-item status and an aggregate summary
  • States O(n log n) time and O(items) space
Key Topics to Cover
State machines
Sorting
Hash maps
Retry semantics
Idempotent event handling
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 distinguish an application exception (retry) from a business exception (never retry)?
  • Events now stream in forever. How do you emit the final status without holding all history?
  • Two events share a timestamp, Failed and Succeeded. What should win and why?
  • How would you flag items stuck InProgress for longer than a timeout?
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

Each queue item starts New. Started moves New or Retrying to InProgress. Succeeded moves InProgress to Successful (terminal). Failed from InProgress increments a failure counter: if fail...

High-Level Design

Sort events by (timestamp, item_id) so the replay is deterministic, then run one pass keeping two dictionaries: state[item] and failures[item]. A final pass tallies statuses. Keeping transitions...


Submit Your Answer
Markdown supported

Related Questions