← Hudson River Trading Interview Insights

Hudson River Trading·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

HRT coding screen, one problem, simulation-style. The problem looked deceptively easy at first glance but the alternating direction logic tripped me up a bit.

Questions Asked (1)

Q1

A bird starts at a given index in an array where positive integers are sticks and zeroes are empty spaces. It alternates collecting the nearest stick to the right, then left, then right, and so on, returning each to its starting position. Return the indices of collected sticks in order, stopping once the total length reaches at least 100.

Algorithms & Data Structures
Author's notes

Spent the first few minutes just re-reading the problem because I kept second-guessing the alternating part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then propose an efficient algorithm using two pointers or a balanced BST to find the nearest sticks alternately. Walk through a small example to validate the approach, and analyze time and space complexity.

Pro tip: Demonstrate strong communication by restating the problem in your own words and discussing trade-offs between different data structures (e.g., two pointers vs. balanced BST) before coding.

1. Clarify the problem

Ask questions to confirm details: Are sticks only positive integers? Can the bird skip empty spaces? What if there are no sticks on one side? Does the total length include only collected sticks? How to handle ties (equidistant sticks)?

2. Outline the algorithm

Describe the high-level approach: maintain pointers to the nearest stick on the left and right, alternate directions, collect sticks, and accumulate total length until it reaches 100. Use a data structure to efficiently find the next stick in each direction.

3. Walk through an example

Choose a small array (e.g., [0, 2, 0, 3, 0, 4]) and simulate the process step by step, showing how the pointers move and the total length increases. This validates the algorithm and catches edge cases.

4. Analyze complexity

Discuss the time and space complexity of your approach. For example, using two pointers with precomputed next-stick arrays gives O(n) time and O(n) space; using a balanced BST gives O(n log n) time and O(n) space.

5. Handle edge cases

Mention how to handle cases like no sticks on one side, starting on a stick, total length exactly 100, or array with fewer than needed sticks. Ensure the algorithm terminates correctly.

Key Points to Mention

  • Two-pointer technique or precomputed next-stick arrays for O(1) nearest stick lookup
  • Alternating direction logic and how to switch sides
  • Accumulating total length and stopping condition (>=100)
  • Edge cases: no sticks on one side, starting on a stick, empty array
  • Time and space complexity trade-offs (e.g., O(n) vs O(n log n))
  • Handling ties when sticks are equidistant (e.g., prefer right first as per problem statement)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.