FastPrepOrder and Batch Open-Close Lifecycle
Problems/Order and Batch Open-Close Lifecycle

Order and Batch Open-Close Lifecycle

Hudson River Trading logoHudson River Trading● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Hudson River Trading phone screen. The original report gives the rules for the order and batch life cycle, including the marker for an open order. We only chose the function interface, which takes parallel arrays, and the rule that the input is well formed. Our version is about 95% the same as the reported question.

Open and close events are stored separately. Every event has a positive timestamp, an order ID, and a batch ID.

Given the parallel arrays for both event files plus queryType and queryId, return [start, end] for the requested lifecycle:

  • For an ORDER query, start is that order's open timestamp. end is its close timestamp, or 0 if it has no close event.
  • For a BATCH query, start is the earliest open timestamp among its orders. If any order in that batch has no close event, end is 0; otherwise, end is the latest close timestamp among those orders.

The input is well formed: every order opens exactly once, closes at most once, and keeps the same batch ID in both files.

Function

getLifecycleWindow(openTimestamps: long[], openOrderIds: String[], openBatchIds: String[], closeTimestamps: long[], closeOrderIds: String[], closeBatchIds: String[], queryType: String, queryId: String) → long[]

Examples

Example 1

openTimestamps = [10,12,15]openOrderIds = ["o1","o2","o3"]openBatchIds = ["b1","b1","b2"]closeTimestamps = [20,25]closeOrderIds = ["o1","o3"]closeBatchIds = ["b1","b2"]queryType = "BATCH"queryId = "b1"return = [10,0]

Batch b1 starts when o1 opens at 10. Order o2 remains open, so the batch end is 0.

Example 2

openTimestamps = [10,12,15]openOrderIds = ["o1","o2","o3"]openBatchIds = ["b1","b1","b2"]closeTimestamps = [20,25]closeOrderIds = ["o1","o3"]closeBatchIds = ["b1","b2"]queryType = "ORDER"queryId = "o1"return = [10,20]

Order o1 opens at 10 and closes at 20.

Example 3

openTimestamps = [5,7,9]openOrderIds = ["a","b","c"]openBatchIds = ["x","x","y"]closeTimestamps = [11,20,15]closeOrderIds = ["a","b","c"]closeBatchIds = ["x","x","y"]queryType = "BATCH"queryId = "x"return = [5,20]

Batch x starts at the earlier open time 5. Both orders close, and the later close is 20.

Constraints

  • The three open arrays have equal positive length; the three close arrays have equal length.
  • All timestamps are positive 64-bit integers, and each close timestamp is at least its order's open timestamp.
  • Every order ID appears exactly once in the open arrays and at most once in the close arrays.
  • A close event uses the same batch ID as its order's open event.
  • queryType is ORDER or BATCH, and queryId identifies an existing order or batch of that type.

More Hudson River Trading Phone Screen questions

  • Format a Signed Integer with CommasPHONE SCREEN · Seen Nov 2026
  • Tilting Maze BallPHONE SCREEN · Seen Oct 2026
  • Tiered Expiring Item StorePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Mean vs Median: Chance of Missing the CenterPHONE SCREEN · Seen Sep 2026
  • Market Data Signal WatcherPHONE SCREEN · Seen Jul 2026
  • Integer to String Without Built-insPHONE SCREEN · Seen May 2026
  • Contact Tracing Through Timed MeetingsPHONE SCREEN · Seen Nov 2024
  • Polydivisible Pandigital NumbersPHONE SCREEN · Seen Feb 2024
  • Defragment a Buffer of ObjectsPHONE SCREEN · Seen Nov 2023
  • Expected People Met Before Someone TallerPHONE SCREEN · Seen Nov 2023

Similar questions at other companies

  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • Realized Gains from a Real-Estate Transaction StreamKikoff · PHONE SCREENKikoff interview questions
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Batched Key Fetch CallbacksAnrok · PHONE SCREEN
  • Earliest Car for Each PassengerWhatNot · PHONE SCREENWhatNot interview questions
  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions

Hudson River Trading interview experiences

  • Hudson River Trading Data Science Interviews: 2 Experiences
  • Hudson River Trading interviews · 2021
  • Hudson River Trading OA · 2021
  • Hudson River Trading interviews · 2022
  • Hudson River Trading OA · 2022
  • Hudson River Trading interviews · 2023
All Hudson River Trading interview questionsSee Hudson River Trading hiring insights
Saved
class Solution {
    public long[] getLifecycleWindow(long[] openTimestamps, String[] openOrderIds, String[] openBatchIds, long[] closeTimestamps, String[] closeOrderIds, String[] closeBatchIds, String queryType, String queryId) {
      // write your code here
    }
}
Checking account…