Split a Message into Length-Limited Parts with Numbered Suffixes
Quick Overview
This Hudson River Trading software engineering question evaluates message splitting under strict length limits with numbered suffixes. It prepares candidates to reason about formatting overhead, boundary cases, and iterative construction of output that satisfies a fixed constraint.
Split a Message into Length-Limited Parts with Numbered Suffixes
Company: Hudson River Trading
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Given a message string and a length limit, split the message into ordered parts. Each part must end with a suffix like `<X/Y>`, where `X` is the 1-based part number and `Y` is the total number of parts. The length of each final part including its suffix must not exceed the limit.
### Constraints & Assumptions
- The message can be long.
- Suffix length depends on the total number of parts.
- Parts should preserve message order.
- If no valid split exists, return an empty result or an error depending on the API contract.
### Clarifying Questions to Ask
- Can a part split anywhere, or only on spaces?
- Is the limit always large enough to hold a suffix and at least one character?
- Should Unicode characters count as bytes or characters?
- What should happen for an empty message?
- Is minimizing the number of parts required?
### What a Strong Answer Covers
```premium-lock What a Strong Answer Covers
```
### Follow-up Questions
- How would you split only on word boundaries?
- How would byte limits change the implementation?
- How would you stream the output?
- How would you prove the chosen number of parts is minimal?
Quick Answer: This Hudson River Trading software engineering question evaluates message splitting under strict length limits with numbered suffixes. It prepares candidates to reason about formatting overhead, boundary cases, and iterative construction of output that satisfies a fixed constraint.
|Home/Software Engineering Fundamentals/Hudson River Trading
Split a Message into Length-Limited Parts with Numbered Suffixes
Given a message string and a length limit, split the message into ordered parts. Each part must end with a suffix like <X/Y>, where X is the 1-based part number and Y is the total number of parts. The length of each final part including its suffix must not exceed the limit.
Constraints & Assumptions
The message can be long.
Suffix length depends on the total number of parts.
Parts should preserve message order.
If no valid split exists, return an empty result or an error depending on the API contract.
Clarifying Questions to Ask
Can a part split anywhere, or only on spaces?
Is the limit always large enough to hold a suffix and at least one character?
Should Unicode characters count as bytes or characters?
What should happen for an empty message?
Is minimizing the number of parts required?
What a Strong Answer Covers Premium
Follow-up Questions
How would you split only on word boundaries?
How would byte limits change the implementation?
How would you stream the output?
How would you prove the chosen number of parts is minimal?