Reported March 2026
Stripesimulation

Order Manager with Partial Cancellations and Indexed Queries

Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Stripe OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Stripe order manager is validating in the wrong order, or scanning every order on each query. Stripe candidates reported it in March 2026, and it's a simulation problem with a sorting flavor. You process CREATE, CANCEL, ORDERS_BY_STATUS and ORDERS_BETWEEN in sequence and return one string per operation. Nothing is hard algorithmically. The trap is a pile of small rules that all have to hold at once. If you blank on the date validation or the index design mid-assessment, StealthCoder runs invisibly on your desktop as a safety net while you recover.

The problem

Implement a lightweight order manager that creates orders, supports partial and full cancellation, and answers indexed status and creation-time queries.
Implement processOrderManager. Process the operations in order and return one result string for every operation.
Operation format
CREATE order_id user_id created_at quantity: create a new order with a unique order ID, a valid user ID, a strict UTC creation timestamp, and a positive quantity. Validate the user ID first, then the timestamp, and then check for a duplicate order ID. Return CREATED, INVALID_USER_ID, INVALID_TIMESTAMP, or DUPLICATE_ORDER. A rejected create has no effect.
CANCEL order_id quantity: cancel a positive quantity from an existing order. The canceled total may equal but never exceed the original quantity. Return PARTIALLY_CANCELLED while some quantity remains, CANCELLED when the remaining quantity becomes zero, ORDER_NOT_FOUND for an unknown ID, or INVALID_CANCEL when the quantity exceeds the remaining amount. A rejected cancellation has no effect.
ORDERS_BY_STATUS status: status is ACTIVE or CANCELLED. Return matching order IDs as one comma-separated string in original creation order, or the empty string when none match. An order is active while its remaining quantity is positive. A fully canceled order is removed from the active set but retained in cancellation and history indexes.
ORDERS_BETWEEN start_timestamp end_timestamp: return every created order whose creation timestamp lies in the inclusive range. Order the result by creation timestamp and then by original creation order for equal timestamps. Include fully canceled orders. Return the empty string when none match, or INVALID_RANGE when either timestamp is invalid or the start is after the end.
Validation rules
A valid user_id contains between 1 and 32 ASCII letters, digits, underscores, or hyphens. A timestamp must be a real UTC instant in exact YYYY-MM-DDTHH:mm:ssZ form using ASCII digits.
Interview follow-ups
The interview report also asked how to optimize status queries and persist runtime data. This callable exercise judges the in-memory behavior above. Maintain status and timestamp indexes rather than scanning every stored order for each query; database persistence remains a discussion follow-up.

Function
processOrderManager(operations: String[]) → String[]

Examples
Example 1
operations = ["CREATE o1 user_1 2026-03-20T09:00:00Z 5","CREATE o2 user-2 2026-03-20T10:00:00Z 3","CANCEL o1 2","ORDERS_BY_STATUS ACTIVE","ORDERS_BETWEEN 2026-03-20T00:00:00Z 2026-03-20T23:59:59Z","CANCEL o1 3","ORDERS_BY_STATUS CANCELLED","ORDERS_BY_STATUS ACTIVE"]
return = ["CREATED","CREATED","PARTIALLY_CANCELLED","o1,o2","o1,o2","CANCELLED","o1","o2"]
After canceling 2 units, o1 remains active with 3 units. The inclusive time query returns both orders. The second cancellation fully cancels o1, so it moves out of the active index and appears in the canceled-status query.
Example 2
operations = ["CREATE order-7 user_7 2026-03-21T12:00:00Z 10","CREATE order-7 user_8 2026-03-22T12:00:00Z 4","CANCEL order-7 11","CANCEL missing 1","CANCEL order-7 4","ORDERS_BY_STATUS ACTIVE"]
return = ["CREATED","DUPLICATE_ORDER","INVALID_CANCEL","ORDER_NOT_FOUND","PARTIALLY_CANCELLED","order-7"]
The duplicate create and over-cancellation are rejected without changing state. Canceling 4 units succeeds and leaves 6, so order-7 is still active.
Example 3
operations = ["CREATE a bad!user 2026-03-21T00:00:00Z 1","CREATE b user_b 2026-02-30T00:00:00Z 1","CREATE c user_c 2026-03-22T08:30:00Z 2","ORDERS_BETWEEN 2026-03-23T00:00:00Z 2026-03-22T00:00:00Z","ORDERS_BETWEEN 2026-03-22T00:00:00Z 2026-03-22T23:59:59Z","ORDERS_BY_STATUS CANCELLED"]
return = ["INVALID_USER_ID","INVALID_TIMESTAMP","CREATED","INVALID_RANGE","c",""]
The first user ID contains an unsupported character, and February 30 is not a real date. Only c is created. The reversed range is invalid; the valid range contains c, and no order is fully canceled.

Constraints
1 <= operations.length <= 100000.
Every operation has one of the documented forms.
order_id is non-empty and contains no spaces.
Every create or cancel quantity is a positive integer no greater than 10^12.
All quantities and cumulative canceled quantities fit in a signed 64-bit integer.
Every status query uses ACTIVE or CANCELLED.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is bookkeeping. Keep a map from order ID to quantity remaining and original quantity, plus a list of order IDs in creation order. For status queries, maintain an active set and a cancelled set, and move an ID only when remaining hits zero. Iterate in creation order so output order is free. For time queries, keep a sorted structure keyed by (timestamp, creation index) and binary search the inclusive range. Since ISO timestamps in this exact format compare correctly as strings, you can sort on the raw string once validated. Pitfalls: checking user ID, then timestamp, then duplicate, in that exact order. Real calendar validation, including leap years and February 30. Rejected operations must change nothing. Fully cancelled orders stay in the time index. Empty string versus INVALID_RANGE is another easy slip. If the date logic eats your time, StealthCoder is the hedge during the live OA.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Order Manager with Partial Cancellations and Indexed Queries cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Stripe's OA.

Stripe reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Order Manager with Partial Cancellations and Indexed Queries FAQ

What's the trick in the Stripe order manager problem?+

Maintain indexes instead of scanning. Use a map for order state, an active set, a cancelled set, and a timestamp-sorted list with creation index as tiebreaker. Then each query is cheap and ordering falls out naturally. The rest is careful validation in the stated order.

How do I validate the timestamp correctly?+

Match the exact pattern YYYY-MM-DDTHH:mm:ssZ with ASCII digits only, then check real calendar values. Month 1-12, day within that month's length including leap years, hour 0-23, minute and second 0-59. February 30 must fail. Don't rely on a lenient date parser that rolls overflow forward.

Why does validation order matter on CREATE?+

The spec says check user ID first, then timestamp, then duplicate order ID. If an input has a bad user and a duplicate ID, the expected answer is INVALID_USER_ID. Reordering your checks gives wrong strings on edge-case tests even when the logic looks fine.

Do cancelled orders show up in ORDERS_BETWEEN?+

Yes. ORDERS_BETWEEN includes fully cancelled orders, since it covers every created order in the inclusive range. Only the active index drops them. Sort by timestamp, then original creation order for ties. Return an empty string if nothing matches, and INVALID_RANGE if a bound is invalid or start is after end.

How do I prepare for this in 48 hours?+

Write the solution once from scratch with a stub of all four operations. Test the three given examples, then add cases for leap-day timestamps, equal timestamps, exact full cancellation, and over-cancellation. Focus on state not changing after rejected operations. That covers most failures on stateful simulation problems like this.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Stripe.

OA at Stripe?
Invisible during screen share
Get it