← Back to blog HRT OA Coding: Window + Prefix Sum + Heap
Hudson River Trading

HRT OA Coding: Window + Prefix Sum + Heap

2026-06-12

Hudson River Trading (HRT) is a top quant trading firm, and its OA is usually done on CodeSignal—coding problems are above-average difficulty and time-pressured. This piece, organized from an oavoservice student's HRT OA debrief, picks three high-frequency coding problems and explains the idea, solution, and complexity, plus how the OA live support / OA interview assist path plugs in—a practical reference for anyone on the quant job hunt and grinding problems.


1. HRT OA overview

Dimension Details
Platform CodeSignal (general coding assessment)
Length ~70–90 minutes
Count 3–4 problems, increasing difficulty
Language Python / C++ / Java (your choice)
Focus Data structures, algorithms, edge handling, time management

HRT's OA leans engineering-implementation + algorithms; the last problem is often above-average, requiring stable code within the time limit that passes all hidden tests.

2. Problem 1: longest subarray with sum at most K (sliding window)

Problem

Given a non-negative array nums and a cap k, find the longest contiguous subarray whose sum is at most k.

Approach

All non-negative → the window sum is monotone, so a sliding window works: the right pointer expands and accumulates; when it exceeds k, the left pointer shrinks; track the max length.

def longest_subarray_at_most_k(nums, k):
    left = 0
    cur = 0
    best = 0
    for right, x in enumerate(nums):
        cur += x
        while cur > k and left <= right:   # shrink until valid
            cur -= nums[left]
            left += 1
        best = max(best, right - left + 1)
    return best

Time complexity: O(n) (each element enters and leaves the window once). Space complexity: O(1).

3. Problem 2: many range-sum queries (prefix sum)

Problem

Given nums and many queries (l, r), return the sum of [l, r] each time.

Approach

Precompute a prefix-sum array; each query is O(1). Ideal when queries far outnumber the array length.

def range_sum(nums, queries):
    n = len(nums)
    prefix = [0] * (n + 1)
    for i, x in enumerate(nums):
        prefix[i + 1] = prefix[i] + x
    return [prefix[r + 1] - prefix[l] for l, r in queries]

Time complexity: preprocessing O(n), each query O(1). Space complexity: O(n).

4. Problem 3: Kth largest in a stream (min-heap)

Problem

Design a class that continuously adds numbers and returns the current k-th largest at any time.

Approach

Keep a size-k min-heap: its top is the k-th largest. If a new element beats the top, replace it, so the heap always holds the largest k.

import heapq

class KthLargest:
    def __init__(self, k, nums):
        self.k = k
        self.heap = nums[:]
        heapq.heapify(self.heap)
        while len(self.heap) > k:
            heapq.heappop(self.heap)

    def add(self, val):
        heapq.heappush(self.heap, val)
        if len(self.heap) > self.k:
            heapq.heappop(self.heap)
        return self.heap[0]            # top = k-th largest

Time complexity: each add is O(log k). Space complexity: O(k).

5. CodeSignal platform notes


FAQ

Q1: How hard is the HRT OA?

Above-average overall—the first two problems are medium, the last leans hard, and it's time-pressured. It values edge completeness and runtime efficiency more than a typical big-tech OA—suited to job seekers who have done LeetCode medium to medium-hard.

Q2: What platform and length is the HRT OA?

Usually CodeSignal, ~70–90 minutes, 3–4 problems of increasing difficulty, supporting Python / C++ / Java.

Q3: Which actions get flagged as anomalies?

Tab switching, copying external code, and long inactivity can all be flagged by behavior monitoring. Staying on the answer page and writing it yourself is the safest approach.

Q4: How to prepare efficiently?

Grind by block—sliding window / prefix sum / heap / hashing—doing 5–8 timed problems per type. For timed mocks and per-problem walkthroughs, the OA live support / OA interview assist path can tailor a plan.


Preparing for the HRT OA?

The HRT OA is time-pressured and edge-sensitive. oavoservice offers full-process HRT practice: timed mocks on sliding-window / prefix-sum / heap / stream questions, CodeSignal environment and behavior-monitoring notes, and question-type prediction by quant role. Coaches include senior engineers with quant and big-tech backgrounds, with end-to-end OA live support / OA interview assist.

Add WeChat Coding0201 now to get HRT questions and mock practice.

Contact