Reported September 2026
Hudson River Tradingbinary search

Obstacle Placement Queries

Reported by candidates from Hudson River Trading's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Hudson River Trading OA. Under 2s to a working solution.
Founder's read

The detail that matters in this Hudson River Trading OA, reported September 2026, is the block that ends at x - 1 and covers x - size through x - 1. Obstacles get added over time, and queries ask whether a range is clear. It looks like a range-check problem, and it is. If you're taking it in the next day or two, the job is picking a structure that handles inserts and range queries fast. Brute force will bite you on large inputs. StealthCoder sits invisibly on your screen as a safety net if you blank on the structure mid-assessment.

The problem

You are given an infinite integer number line and an array operations. Process the operations in order while maintaining the coordinates that contain obstacles.
[1, x]: Place an obstacle at coordinate x. Coordinate x is guaranteed to contain no obstacle when this operation is performed.
[2, x, size]: Check whether a block of length size can end immediately before coordinate x. The block would occupy every integer coordinate from x - size through x - 1. Append '1' to the answer if none of those coordinates contains an obstacle; otherwise append '0'. This operation only checks feasibility and does not place the block.
Return the binary string formed by the results of all type-2 operations in their original order.

Function
solution(operations: int[][]) → String

Examples
Example 1
operations = [[1,2],[1,5],[2,5,2],[2,6,3],[2,2,1],[2,3,2]]
return = "1010"
Place obstacles at coordinates 2 and 5.
The block before 5 covers 3 and 4, so append 1.
The block before 6 covers 3, 4, and 5; coordinate 5 is blocked, so append 0.
The block before 2 covers only coordinate 1, so append 1.
The block before 3 covers coordinates 1 and 2; coordinate 2 is blocked, so append 0.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: a query is 1 exactly when no obstacle lies in [x - size, x - 1]. So you only need the largest obstacle strictly less than x. If that obstacle is below x - size, answer 1, else 0. That's a predecessor query on a dynamic set. Use a sorted set with binary search for the floor lookup, or a segment tree or Fenwick tree over coordinates if you compress them offline. Since the operations are all known upfront, offline coordinate compression works fine. Common pitfalls: off-by-one on the range (the end is x - 1, not x), and treating an obstacle at x itself as blocking. It doesn't. Also don't scan the range per query, that's O(size) each. If the sorted-set idea slips away under pressure, StealthCoder is the hedge for the live OA, reading the problem and handing you the structure.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Obstacle Placement Queries cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Hudson River Trading's OA.

Hudson River Trading reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Obstacle Placement Queries FAQ

What's the trick in Obstacle Placement Queries?+

Reduce each check to one predecessor lookup. Find the largest obstacle strictly less than x. If it's less than x - size, the block fits and you append 1. Otherwise append 0. No range scanning needed.

Does an obstacle at x itself block the placement?+

No. The block covers x - size through x - 1 only. In the example, the block before 5 with size 2 covers 3 and 4, so the obstacle at 5 doesn't matter and the answer is 1.

What data structure should I use?+

A sorted set with floor lookup is the cleanest. In Python, use bisect on a sorted list, though insertion is linear. For guaranteed speed, compress coordinates offline and use a segment tree or Fenwick tree storing the max obstacle position.

How hard is this one really?+

Medium. The idea is short once you see the predecessor framing. The difficulty is spotting it quickly and avoiding off-by-one errors. A brute-force range scan passes small cases and fails big ones.

How do I prepare in 48 hours for a Hudson River Trading OA?+

Practice dynamic set problems: predecessor and successor queries, binary search on sorted lists, and basic segment trees. Write the solution once by hand and test it against the example string 1010. Edge cases matter: empty set, size larger than x, and negative coordinates.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Hudson River Trading.

OA at Hudson River Trading?
Invisible during screen share
Get it