9.17 HRT OA latest sharing (CodeSignal version-70min 4 questions all through review)

967 Views
No Comment

Share a set of recent walks with trainees HRT OA. This student is a candidate for a quant/trading firm this year, and he has done a lot of CodeSignal OA (Citadel, Optiver, etc.) before, so he is familiar with common arrays and simulation questions. This time, when I encountered HRT's OA, the overall question types were still familiar.

This OA has 4 questions in 70 minutes, and the difficulty level is relatively balanced. My student got all the ACs in 25 minutes and spent the rest of the time checking the edge cases. by the way, there is another version of HRT: 3 questions in 150 minutes, in which the third question has two levels and the second question has to be written on top of the first one, which is more time-consuming.

Hudson River Trading Exclusive Exam Questions Sharing

Problem 1: Build Obstacles and Check Blocks on Number Line

Task: Implement code to support two operations on an infinite integer number line for building obstacles and checking block feasibility.

Operation Types:

[1, x]:: Build an obstacle at coordinate X.

[2, x, size]:: Check if a block centered at X (extending size - 1 Each way) can be built. "1" or "0".

Output: A binary string of all results.

👉 The difficulty with this question is that you have to dynamically insert obstacle points and also quickly determine if there are any obstacles in the interval. Violent scanning doesn't work, and it times out with large amounts of data.
A common solution is to use ordered sets:

  • Insertion disorders:set.add(x), O(log n).
  • consult (a document etc) [x-(size-1), x+(size-1)]: bisect the set to find >= left of the barrier, if it ≤ right it indicates a conflict.

Python can be used with bisectJava with TreeSetC++ with set.lower_bound.
Boundaries to watch out for:size=1 When it is a single point, there may be exactly one obstacle; and the title guarantees that there is no obstacle at the insertion position, but be careful about overflowing the range when checking.

Problem 2: Find First Day to Reach Target Visits

Task: Given a visits array (daily website visitors), find the index I of the first day where cumulative visits reach or exceed target.

Rules: Return I if reached, else -1.

Complexity: No worse than O(n²).

👉 This question is actually a giveaway. The idea is to prefix and:

sum = 0
for i in range(n):
    sum += visits[i]
    if sum >= target: return i  

Returning i is sufficient.

Easy to get it wrong:

If target starts with ≤ 0, should we just return 0, or should we start accumulating from day 0 in general?

If the array is empty, return -1 directly.

There's also an advanced idea: if target has many queries, you can do prefixes and arrays first, and then bisect the search. But this exam only asks once, so just O(n) it.

Problem 3: Find Lexicographically Smallest String

Task:: Perform all possible prefix or suffix reversals on word and return the lexicographically smallest result.

Rules: Reverse first k or last k characters.

Complexity: No worse than O(n²).

👉 This question looks a bit tricky, but you can actually get by with violence:

Iterate over all prefix lengths k:word[:k][::-1] + word[k:]

Iterate over all suffix lengths k:word[:-k] + word[-k:][::-1]

Record all results, taking the smallest dictionary order.

Complexity O(n²), the restrictions given in the title allow this.

Easy to get it wrong:

Forget the case k = n (the whole string reversed).

In Python, it's easiest to use slice reversal directly, whereas in C++ you have to write reverse().

If there are multiple results with the same dictionary order, just return one of them.

Problem 4: Simulate Bubble - Popping Game

Task: Simulates a bubble elimination game. When you click on a cell, you eliminate that point and its diagonal neighbors of the same color, after which the empty space has to fall.

Rules:

Clicking on space doesn't respond.

After elimination is complete, all columns perform a gravity drop.

Input: Initial bubbles board + operations.

Output: The final board after the operation is completed (spaces are denoted by 0).

👉 This is the most complicated question in the whole field, you have to do elimination + gravity drop at the same time.
Practice:

Elimination section: DFS or BFS, starting from the clicked point, go only in diagonal direction, and continue to expand when encountering the same color, setting these points to 0.

gravitational drop: For each column, sweep from the bottom to the top, squashing any non-zero numbers to the bottom, and filling in the remaining tops with zeros.

Easy to get it wrong:

Tap on a space to skip it or it will report an error.

The "same color diagonal neighbors" are the 4 diagonal directions, not including up, down, left and right.

Gravity must be listed as a unit, not treated line by line.

The overall complexity is roughly O(m × rows × cols), which is sufficient under the scope of the topic.

From brushing up on questions to assisting in the real world, we'll help you fall into fewer holes and get more Offers.

This HRT OA is basically a hodgepodge of popular CodeSignal questions, and the difficulty is more simulation and detail-oriented than pure algorithmic questions. Be sure to pay attention to time allocation on the exam and don't get stuck on the last question.

If you are also preparing for interviews with quant OA like HRT / Citadel / Jane Street or other big North American companies, you don't really need to go it alone at all. We can provide OA Writing(HackerRank / CodeSignal / NiuKe full coverage), remote voice assistance, mock interview accompaniment, will also help you remind the edge case at key points to ensure efficiency and correctness.

author avatar
jor jor
END
 0
Comment(No Comment)