Reconstruct Final Eats Order States From Out-of-Order Events

Last updated: November 29, 2026

Quick Overview

Uber Eats order events (order_id, status, timestamp) arrive out of order from several services. Replay each order's events in timestamp order through a state machine that allows forward jumps but ignores backward moves and cancellations after pickup, and return each order's final status and the number of ignored events.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Uber Eats order events (order_id, status, timestamp) arrive out of order from several services. Replay each order's events in timestamp order through a state machine that allows forward jumps but ignores backward moves and cancellations after pickup, and return each order's final status and the number of ignored events.

A data-flavored state machine question in the style of Uber's technical screens, based on the Eats order lifecycle (placed, accepted, preparing, picked up, delivered). The interviewer checks grouping, ordering, and a clear rule set for messy real-world events.

What the Interviewer Expects
  • Groups events by order and sorts each group by time
  • Encodes status order as ranks so forward jumps are allowed
  • Ignores regressions and late cancellations, counting them
  • Breaks timestamp ties deterministically
  • Explains how a streaming version would handle late events
Key Topics to Cover
State machines
Sorting
Grouping
Event ordering
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 process this as a stream with a watermark for late events?
  • What if two events share a timestamp but disagree?
  • How would you alert when an order has been stuck in preparing too long?
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

Ranks: placed 0, accepted 1, preparing 2, picked_up 3, delivered 4. cancelled is legal only while the current rank is below picked_up. Delivered and cancelled are terminal. Missing intermediate even...

High-Level Design

Bucket events by order_id. Sort each bucket by (timestamp, rank) so a same-timestamp tie resolves in lifecycle order. Start in a virtual state of rank -1. For each event: if the current state is t...


Submit Your Answer
Markdown supported