Validate an Order Lifecycle Event Log Against Allowed Transitions

Last updated: November 29, 2026

Quick Overview

Order status events arrive as (order_id, status) pairs in log order. Using a table of allowed transitions, report for each order the first event that breaks the lifecycle, such as an order delivered before it was picked.

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

0

0

0 solved


Order status events arrive as (order_id, status) pairs in log order. Using a table of allowed transitions, report for each order the first event that breaks the lifecycle, such as an order delivered before it was picked.

Walmart order management emits status events for every online order, and downstream teams need to catch impossible sequences caused by bugs or replays. The Walmart Labs phone screen checks that you model the lifecycle as a state machine and process an interleaved log in one pass.

What the Interviewer Expects
  • Represent the lifecycle as a transition table
  • Track the current state per order in a dictionary
  • Require CREATED as the first event
  • Report only the first violation per order
  • Keep the solution single pass and data driven
Key Topics to Cover
state machines
simulation
hash maps
log validation
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 tolerate duplicate events caused by at-least-once delivery?
  • What if events for one order can arrive slightly out of order?
  • How would you also flag orders stuck in PICKED for more than two hours?
  • How would you add a new state such as READY_FOR_PICKUP without code changes?
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 (order_id, status) in the order they were logged, with many orders interleaved. A transition table maps each state to the states allowed next. The first event of each order must be CR...

High-Level Design

Keep state[order_id] holding the last valid status. For each event: unknown status is a violation; a new order must start with CREATED; otherwise the new status must be in allowed[current]. Puttin...


Submit Your Answer
Markdown supported

Related Questions