Reported May 2026
Capital Onehash table

Dynamic Wall Building and Range Query

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

Get StealthCoderRuns invisibly during the live Capital One OA. Under 2s to a working solution.
Founder's read

Capital One asked this in May 2026: maintain a line of length n, support build operations that place walls at specific indices, and answer range queries asking whether a wall exists in [l, r]. It's a classic interval membership problem. You'll need to track which indices have walls and answer range containment queries efficiently. The pattern is straightforward once you see it, but the implementation matters under load. StealthCoder will spot the right data structure choice if you freeze on the live OA.

The problem

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem. Original prompt Problem Maintain a 1D line of length n with indices 0..n-1, initially with no walls. You are given a sequence of operations of two types: build i: build a wall at index i (idempotent). query l r: check whether there exists at least one wall in the inclusive range [l, r]. For each query output: 1 if the range contains a wall otherwise 0 Return/output the list of query results in order. Input Integer n List of operations operations Output List of 0/1 (or printed space-separated) Constraints (suggested) 1 <= n <= 2e5 1 <= len(operations) <= 2e5 indices are valid Examples n=5, ops=[query 0 4] → 0 n=5, ops=[build 2, query 0 4] → 1 n=5, ops=[build 2, query 3 4] → 0 n=5, ops=[build 1, build 3, query 2 2, query 0 3] → 0 1 n=3, ops=[build 0, build 0, query 0 0, query 1 2] → 1 0 Function Description Complete solveOneDynamicWallRangeQuery. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters. The returned string must match the expected standard output for the sample input. Use the limits and requirements stated in the prompt.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is recognizing this as a range query problem over a set of points. You can solve it naively by storing walls in a set and checking if any element in the set falls within [l, r] for each query, which works fine for n and operations both up to 2e5. A set or hash-table approach is bulletproof here. If you want to optimize further, a segment tree or Fenwick tree over a boolean array works, but it's overkill. The idempotency of build means building twice at the same index is just one wall. For each query, iterate the wall set or use binary search (lower_bound) to check if any wall exists in the range. StealthCoder handles the implementation detail you might second-guess during the OA.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Dynamic Wall Building and Range Query 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Capital One's OA.

Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Dynamic Wall Building and Range Query FAQ

Do I need a segment tree for this?+

No. A set of wall indices is enough. For each query, use binary search (lower_bound) on the sorted set to check if any element falls in [l, r]. This runs in O(log w) per query where w is the number of walls. Fast enough for the constraints.

What's the edge case I'm missing?+

Building the same index twice should be treated as a single wall (idempotent). Make sure your set or data structure handles that. Also, a query range with no walls must return 0. Empty ranges at the boundary are valid.

How do I check if [l, r] contains a wall quickly?+

Use set.lower_bound(l). If it returns an iterator <= r, a wall exists in the range. If it's greater than r or end(), no wall exists. One binary search per query.

Is this still a common Capital One pattern?+

Yes. Range query with point updates is perennial. This version is tame because it's read-heavy and the query is just existence. It's a warm-up before harder segment tree or lazy propagation problems.

How do I prepare in 48 hours if I blank on the OA?+

Memorize the set binary search pattern: lower_bound(l) checks if any element is in [l, r]. Write one clean solution with a set, test it on the examples, and know your language's set methods cold.

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

OA at Capital One?
Invisible during screen share
Get it