PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Hudson River Trading

Wrap a Fixed-Chunk Stream Reader with Arbitrary-Length Reads

Last updated: Jul 2, 2026

Quick Overview

This Hudson River Trading software engineering question asks candidates to wrap a fixed-chunk stream reader with arbitrary-length reads. It is useful for practicing buffering, state carried across calls, and clean handling of end-of-stream behavior.

  • hard
  • Hudson River Trading
  • Software Engineering Fundamentals
  • Software Engineer

Wrap a Fixed-Chunk Stream Reader with Arbitrary-Length Reads

Company: Hudson River Trading

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Technical Screen

You are given a low-level stream API that reads exactly 4096 bytes at a time. Design a wrapper API `read(n)` that returns any requested number of bytes, including values smaller than 4096 or not divisible by 4096. Preserve unused bytes for future reads. ### Constraints & Assumptions - The underlying stream returns up to or exactly 4096 bytes depending on EOF behavior. - The wrapper may be called repeatedly. - Unused bytes from a chunk must be buffered. - The API should handle end of stream. ### Clarifying Questions to Ask - Does the underlying API block until 4096 bytes or return fewer at EOF? - Should `read(n)` return fewer than n bytes at EOF or raise? - Can n be zero? - Is the wrapper single-threaded? - Should bytes or strings be returned? ### What a Strong Answer Covers ```premium-lock What a Strong Answer Covers ``` ### Follow-up Questions - How would you make it thread-safe? - How would you support peek? - How would buffering affect memory usage? - How would you adapt this to async I/O?

Quick Answer: This Hudson River Trading software engineering question asks candidates to wrap a fixed-chunk stream reader with arbitrary-length reads. It is useful for practicing buffering, state carried across calls, and clean handling of end-of-stream behavior.

Related Interview Questions

  • Explain Large Memory Allocation, Swap, and C++ Inline Trade-offs - Hudson River Trading (hard)
  • Design an Indexable Deque with O(1) Access - Hudson River Trading (hard)
  • Find a Local Minimum in One and Two Dimensions - Hudson River Trading (hard)
  • Minimize Array Amplitude After Removing a Contiguous Block - Hudson River Trading (medium)
  • Count Matrix Cells Whose Row and Column Neighbors Match - Hudson River Trading (medium)
|Home/Software Engineering Fundamentals/Hudson River Trading

Wrap a Fixed-Chunk Stream Reader with Arbitrary-Length Reads

Hudson River Trading logo
Hudson River Trading
Jul 2, 2026, 7:02 PM
hardSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

You are given a low-level stream API that reads exactly 4096 bytes at a time. Design a wrapper API read(n) that returns any requested number of bytes, including values smaller than 4096 or not divisible by 4096. Preserve unused bytes for future reads.

Constraints & Assumptions

  • The underlying stream returns up to or exactly 4096 bytes depending on EOF behavior.
  • The wrapper may be called repeatedly.
  • Unused bytes from a chunk must be buffered.
  • The API should handle end of stream.

Clarifying Questions to Ask

  • Does the underlying API block until 4096 bytes or return fewer at EOF?
  • Should read(n) return fewer than n bytes at EOF or raise?
  • Can n be zero?
  • Is the wrapper single-threaded?
  • Should bytes or strings be returned?

What a Strong Answer Covers Premium

Follow-up Questions

  • How would you make it thread-safe?
  • How would you support peek?
  • How would buffering affect memory usage?
  • How would you adapt this to async I/O?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Hudson River Trading•More Software Engineer•Hudson River Trading Software Engineer•Hudson River Trading Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.