FastPrepTruck Position Subscriber
Problems/Truck Position Subscriber

Truck Position Subscriber

Optiver logoOptiver● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optiver online assessment. The subscription behavior, the delta updates, the ordering rule, and the sample match the report at about 97%. The report does not give input limits or say what happens on a repeated subscription. We chose those and state them here.

A central server tracks truck positions. Local clients subscribe through one subscriber service so they receive only the truck updates they need.

Truck i starts at initialPositions[i] = [x, y]. Process these operations in order:

  • U truckId deltaX deltaY moves that truck. The server position always changes, even when no client has subscribed yet.
  • S clientId truckId subscribes the client and immediately returns the truck's current position. Later duplicate subscriptions are idempotent but still return the current position.
  • R clientId returns every update to any truck that client subscribed to after that subscription and since the client's previous request. Preserve the original global update order, then clear those pending updates for that client.

Return one string for every subscription result and every delivered update. Use S clientId truckId x y for a subscription and U clientId truckId deltaX deltaY for a delivered update.

Function

truckPositionUpdates(initialPositions: double[][], operations: String[]) → String[]

Examples

Example 1

initialPositions = [[2,3]]operations = ["U 0 1.5 2.5","S 0 0","U 0 1 2","U 0 -0.5 -0.5","S 1 0","R 0","U 0 1 1","R 1"]return = ["S 0 0 3.5 5.5","S 1 0 4 7","U 0 0 1 2","U 0 0 -0.5 -0.5","U 1 0 1 1"]

The first update changes the server position before any subscription. Client 0 later receives two deltas, while client 1 receives only the delta that occurred after its own subscription.

Constraints

  • 1 <= initialPositions.length, operations.length <= 10^5
  • Every truck ID is a valid zero-based row index.
  • Client IDs are nonnegative integers.
  • Coordinates and deltas are finite decimal values.
  • A request names a client that has subscribed at least once.

More Optiver Online Assessment questions

  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026
  • Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026
  • Fastest Average Speed over a Rolling KilometerOA · Seen Sep 2026
  • Multi-Level Inventory Storage SystemOA · PHONE SCREEN · Seen Aug 2026
  • Proportional Momentum Investment StatisticsOA · Seen Aug 2026
  • Count Bounded Share TransactionsOA · Seen Aug 2026
  • Count Ordered Size SequencesOA · Seen Aug 2026
  • Profitable Currency Exchange CycleOA · Seen Aug 2026
  • Construct Binary Tree S-ExpressionOA · Seen Jul 2026

Similar questions at other companies

  • Per-Client Sliding-Window Rate LimiterGeneral Motors · OA
  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
  • Recent Event Stream QueriesSnowflake · PHONE SCREENSnowflake interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Per-Client Sliding-Window Rate LimiterNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Article Vote TrackerRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Completions API Rate LimiterCursor · PHONE SCREENCursor interview questions
  • Restaurant Waitlist with Exact-Size TablesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Dynamic Least-Loaded Job DispatcherCresta · PHONE SCREENCresta interview questions

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public String[] truckPositionUpdates(double[][] initialPositions, String[] operations) {
      // write your code here
    }
}
Checking account…