Centered Block Placement Queries
Reported by candidates from Roblox's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Roblox reported this one in October 2026, and it looks like a geometry problem but it isn't. Strip the "centered block" language and you're left with a dynamic set of points and one question: is there any point inside [x - size + 1, x + size - 1]? That's an ordered-set range query, nothing more. With up to 100000 queries on coordinates out to a billion, brute force dies fast. If you blank during the assessment, StealthCoder runs invisibly on your desktop and hands you the structure when your head goes empty. Know the shape before you sit down, though.
The problem
Process queries on an infinite integer number line while maintaining obstacle coordinates. [1, x] places an obstacle at coordinate x. That coordinate is guaranteed to be empty. [2, x, size] checks a centered block whose occupied integer coordinates run from x - size + 1 through x + size - 1, inclusive. Append '1' when the entire range is obstacle-free and '0' otherwise. A check does not place a block. Return the results of all checks as one binary string. Function processBlockQueries(queries: int[][]) → String Examples Example 1 queries = [[2,0,3],[1,2],[2,0,3],[2,-3,2]] return = "101" The first check covers -2 through 2 and is clear. After inserting at 2, the same range is blocked. The final check covers -4 through -2 and remains clear. Example 2 queries = [[1,5],[2,5,1],[2,4,1],[2,3,3]] return = "010" A size-one check covers only its center. The last range covers 1 through 5 and includes the obstacle. Constraints 1 <= queries.length <= 100000. Insertion queries have two integers and check queries have three integers. -10^9 <= x <= 10^9 and 1 <= size <= 10^9. Inserted obstacle coordinates are distinct.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that you only need the nearest obstacle to the range, not every obstacle. Keep obstacles in a sorted structure, find the smallest obstacle >= left (lower bound), and check whether it's <= right. If yes, output 0. Otherwise 1. That's O(log n) per query. In Java, use a TreeSet with ceiling(left). In C++, use std::set with lower_bound. Python has no built-in sorted set, so you'd need a sorted list with bisect (insertion is O(n) but often passes) or an offline approach: read all queries, compress coordinates, and use a Fenwick or segment tree for counts. The common pitfalls are off-by-one on the range (x - size + 1 to x + size - 1, inclusive) and overflow when computing with 10^9 values in a 32-bit int. A size of 1 covers only the center. If you freeze on the data structure choice live, StealthCoder is the hedge, but the ceiling lookup is the whole problem.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Centered Block 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Roblox's OA.
Roblox 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.
Centered Block Placement Queries FAQ
What's the trick in Centered Block Placement Queries?+
Reduce each check to a range-emptiness test. Compute left = x - size + 1 and right = x + size - 1, find the smallest obstacle at or above left, and see if it's within right. If it is, append 0. Otherwise append 1. Everything else is bookkeeping.
How hard is this Roblox OA question really?+
Medium at most. The logic is short once you spot the ordered-set lookup. The difficulty is language support. Java and C++ give you TreeSet and set for free. In Python you need bisect or an offline coordinate-compression approach, and that takes more care.
Can I just scan all obstacles for each check?+
No. With 100000 queries, a linear scan per check can reach about 10^10 operations in the worst case. Coordinates reach 10^9, so you can't mark an array either. You need sorted lookup in O(log n) or a compressed tree.
What edge cases break solutions here?+
Off-by-one on inclusive bounds is the big one. Size 1 must check only the center. Also watch negative coordinates, obstacles placed exactly at the range edge, and integer overflow if you use 32-bit ints with values near 10^9 plus size.
How do I prepare for this in 48 hours?+
Practice sorted-set lower-bound lookups in your OA language until they're automatic. Write this one from scratch once, test both examples, then test edge-touching obstacles. Also rehearse the offline option: collect coordinates, compress, and query a Fenwick tree for counts.