FastPrepRead a File from Distributed Chunks
Problems/Read a File from Distributed Chunks

Read a File from Distributed Chunks

Hudson River Trading logoHudson River Trading● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Hudson River Trading new grad onsite interview. The report describes a C++ file reader over chunks stored in different places, and it requires exception handling. It does not give the low-level API, the processing rule, or the exact failure rules. We rebuilt these with fixed rules. Our version is about 75% the same as the reported question.

A file is split into chunkCount chunks. Each chunk has an ID, and the IDs the file needs are exactly 0 through chunkCount - 1. The chunks are kept in different storage places, and their responses come back in no particular order. The arrays chunkIds, chunkData, and readable describe these responses.

Rebuild the whole file: join the chunk data in increasing ID order and return it.

Return READ_ERROR instead if any of these is true:

  • An ID the file needs is missing.
  • An ID appears more than once, or is outside the needed range.
  • The three response arrays do not all have the same length.
  • A chunk the file needs is not readable.

A readable chunk may hold an empty string. That is fine: its data still counts as part of the file.

Function

readLogicalFile(chunkCount: int, chunkIds: int[], chunkData: String[], readable: boolean[]) → String

Examples

Example 1

chunkCount = 3chunkIds = [2,0,1]chunkData = ["!","Hello ","world"]readable = [true,true,true]return = "Hello world!"

The responses arrive out of order. Sorted by ID, chunk 0 is "Hello ", chunk 1 is "world", and chunk 2 is "!". Joining them gives "Hello world!".

Example 2

chunkCount = 3chunkIds = [0,1,1]chunkData = ["a","b","c"]readable = [true,true,true]return = "READ_ERROR"

ID 1 appears twice and ID 2 is missing, so the answer is READ_ERROR.

Example 3

chunkCount = 2chunkIds = [1,0]chunkData = ["tail","head"]readable = [false,true]return = "READ_ERROR"

The chunk with ID 1 cannot be read, so the file cannot be rebuilt and the answer is READ_ERROR.

Constraints

  • 1 <= chunkCount <= 10^5
  • 0 <= chunkIds.length, chunkData.length, readable.length <= 10^5
  • The total length of all strings in chunkData is at most 2 * 10^5.
  • Chunk data contains printable ASCII characters.

More Hudson River Trading interview questions

  • Tiered Expiring Item StorePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Aligned Free-List Memory AllocatorONSITE INTERVIEW · Seen Aug 2026
  • Best Expected Result in Simplified BlackjackONSITE INTERVIEW · Seen Apr 2025
  • Format a Signed Integer with CommasPHONE SCREEN · Seen Nov 2026
  • Order and Batch Open-Close LifecyclePHONE SCREEN · Seen Nov 2026
  • Count Palindrome Addition ChoicesOA · Seen Nov 2026
  • Tilting Maze BallPHONE SCREEN · Seen Oct 2026
  • Count Multiples of Three with Two SevensOA · Seen Oct 2026
  • Recursively Expanded Shell Command CountsOA · Seen Oct 2026
  • Rotate Matrix Regions Around the DiagonalsOA · Seen Oct 2026

Similar questions at other companies

  • P&L Leaderboard OperationsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Schedule Invoice Emails and DelinquenciesStripe · ONSITE INTERVIEWStripe interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • HTTP Request RedirectionAmazon · OA
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Credit Card Command ProcessorChime · PHONE SCREEN
  • Macaron Order with Set DiscountsShopify · OAShopify interview questions
  • Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions
  • Popular and Instant-Runoff Election WinnersCoursera · PHONE SCREEN

Interview reports that mention this question

  • Hudson River Trading interviews · 2026
  • HRT Python-Track Interview Questions, Answered: Dicts, the GIL, Memory, OS and Debugging

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
All Hudson River Trading interview questionsSee Hudson River Trading hiring insights
Saved
class Solution {
    public String readLogicalFile(int chunkCount, int[] chunkIds, String[] chunkData, boolean[] readable) {
      // write your code here
    }
}
Checking account…