HackTheRounds Interview Experiences

Hudson River Trading Software Engineer Interview Experience (2026) - CodeSignal OA with Order Book Matching, Offer

HRT SWE CodeSignal OA walkthrough: order book matching via two pointer greedy, sliding window unique substring rewrite, and Best Time to Buy/Sell Stock IV DP. O

By Anonymous ยท 2026-04-13

Background

Wrapped up Hudson River Trading's software engineer OA last week and came away with an onsite invite, so here is the playbook. I am a new grad out of a masters program with a year of systems-heavy C++ internship experience. HRT had been a stretch on my list because of the HFT reputation, and their OA is exactly what you would expect from a prop shop that hires for raw problem solving: three algorithmic problems on CodeSignal with just enough trading flavor on top to sound intimidating. Strip the market narrative and every question is a classic interview pattern underneath.

Timeline

OA Format (CodeSignal, 90 min)

Three coding problems, C++ and Python available. I used C++ because HRT's own engineers code in C++ and I wanted the style to feel natural. Difficulty curve was shallow-then-steep. Problems 1 and 2 were under 20 minutes each. Problem 3 ate the rest of my time.

OA Problem 1: Order Book Matching

Problem: Given a list of buy and sell orders with price, quantity, and type, match a buy against a sell whenever the buy price is greater than or equal to the sell price. Return the total executed volume across all matches. One example: [[100,5,'B'], [90,3,'S'], [95,2,'S'], [105,4,'B']] returns 5 .

This is the classic two-pointer greedy after sorting. Sort buys by price descending, sort sells by price ascending, then walk two pointers. Whenever the current buy price is at least the current sell price, execute a match of size min(buy qty, sell qty) , subtract from both, and advance whichever ran out. If the top buy cannot cross the top sell, stop. That is O(n log n) from the sort and O(n) for the walk.

The trap is letting partial fills confuse you: do not advance both pointers on every match, advance only the side that exhausted. I also saw one candidate in a Discord post-mortem claim they ran a priority queue, which works but is strictly slower and shows you did not notice the two-sort shortcut. HRT reads code, so keep it flat.

Practice it: [[problem/871?company=42|Watcher Path Escape]]

OA Problem 2: Minimum Transformations for Unique Substrings

Problem: Given a string s and a window length k , compute the minimum number of character replacements so that every contiguous substring of length k has all distinct letters. For s = "aabbcc" and k = 3 , the answer is 2 .

Sliding window over counts. Keep a HashMap<char, int for the current window. When a window contains a duplicate, you must change at least one of the offending characters. The greedy that passed my tests was: track how many positions in the current window are "extras" (appear more than once in this window), add that number to a rolling total, and slide. The subtlety is that a single replacement can kill a duplicate in multiple overlapping windows, so you cannot just sum extras per window. Instead, maintain a scheduling-flavored counter of unresolved extras and pay one replacement each time you hit a window that is still not clean.

Complexity is O(n) with the window kept by a fixed-size count array over the lowercase alphabet. I did not reach the fully optimal greedy during the round but got enough test cases to score well.

OA Problem 3: Optimal Trade Execution

Problem: You are given an array prices of daily stock prices and an integer k for the maximum number of transactions. You can hold at most one share at a time. Return the maximum profit achievable. One example: prices=[3,2,6,5,0,3], k=2 returns 7 .

This is Best Time to Buy and Sell Stock IV. The shortcut you need on the spot: when k is at least n/2 , you can take every positive price jump, because there is no binding transaction budget. That path is O(n) . Otherwise fall into the DP with two states per transaction count: hold[j] and cash[j] , updated in place. Recurrences are the standard pair: on each day, either do nothing or flip the state by buying or selling. O(n k) time, O(k) space if you roll the arrays.

I blew twelve minutes trying to merge the two shortcuts into one pass, which got tangled on the edge case where k is exactly n/2 . Cleanest answer is to check the shortcut condition explicitly, then branch. Also, if you use Python, remember to initialize hold[j] = -infinity so the first day's buy decision is forced rather than compared against an implicit zero.

Result

Onsite invite came 8 business days later. The recruiter shared that problem 1 had the highest weight and problem 3 was the tiebreaker. She specifically called out that candidates who used the two-pointer approach on problem 1 scored higher than those who used heaps, which matches what I expected.

Tips

  1. Code in C++ if you can at all write it cleanly. HRT's onsite is C++-heavy and the OA is the first signal of which language you default to. Python is fine if your C++ is shaky, but if you can write idiomatic C++17 without fumbling STL, do it. Recruiters told me directly this was a tiebreak signal.
  2. On the order book matcher, sort opposite directions and two-pointer. Do not reach for priority queues on problem 1. The two-sort two-pointer solution is a style test. Heap-based solutions parse as overengineering and run slower on the stress tests.
  3. Know Best Time to Buy and Sell Stock IV cold. Both the `k >= n/2` shortcut and the `O(n * k)` DP. HRT recycles this exact problem structure with different narratives. If you cannot write the recurrence in under five minutes, drill it until you can.
  4. Use `__builtin_popcount` and STL freely. The CodeSignal C++ runner has all the standard library features. I saw a few people rewrite things like `std::accumulate` from scratch and lose time. Trust the stdlib.
  5. Practice on CodeSignal specifically, not LeetCode. The CodeSignal UI quirks (no autocomplete, strict timeout enforcement, stdin format differences on array problems) cost real minutes if you first see them during the timed attempt. Do at least three CodeSignal mock sessions before the real thing.
  6. Leave problem 3 at least 35 minutes. Problems 1 and 2 are warm-ups, problem 3 is the real test. If you have not finished problem 1 inside 20 minutes, move on. The grading clearly weights problem 3, and a half-correct problem 3 beats a perfect problem 2 with a blank problem 3.

HRT's OA rewards exactly what the shop cares about: clean code, right abstraction first, no overengineering. If you can reduce every trading narrative to its algorithmic skeleton and then pick the shortest path, you will do well here.