Reported July 2026
Targetsimulation

First-Available Seat Booking

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

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

Target's July 2026 OA has a seat booking question that looks like a system design prompt and isn't. Strip the ticketing story and you're left with one counter. You hand out seats 1 through n in order, then return -1 once they run out. If you've got the invite and 48 hours, this is the kind of problem that rewards seeing through the wrapper fast. Don't build a heap or a set unless you want to overthink it. If you blank on the live assessment, StealthCoder runs invisibly as a safety net and surfaces the answer while you keep typing.

The problem

A ticket-booking system has n available seats numbered from 1 through n. It receives q booking requests.
Process the requests in their given order. Each assignment completes atomically before the next request. For each request, assign and return the lowest-numbered seat that has not already been assigned. If no seat remains, return -1 for that request.
Return an array containing the result of every request.
Implement bookFirstAvailableSeats(n, q).

Function
bookFirstAvailableSeats(n: int, q: int) → int[]

Examples
Example 1
n = 3
q = 5
return = [1,2,3,-1,-1]
The first three requests receive seats 1, 2, and 3. The remaining requests find no available seat.
Example 2
n = 1
q = 1
return = [1]
The single request receives the only available seat.

Constraints
1 <= n <= 100000.
1 <= q <= 100000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that nothing ever gets released. Seats are only assigned, never freed, so the lowest unassigned seat is always the next integer after the last one given out. Keep a pointer starting at 1. For each of the q requests, if the pointer is at most n, append it and increment. Otherwise append -1. That's O(q) time and O(q) output space. The common pitfall is overengineering: a min-heap of seats, a sorted set, or a boolean array scan per request. A scan makes it O(n*q), which is 10^10 at the limits and will time out. Also watch the off-by-one on the boundary, since seat n is valid and seat n+1 isn't. Check against example 1: n=3, q=5 gives [1,2,3,-1,-1]. If your mind goes blank on the live OA, StealthCoder is the hedge that reads the prompt and gives you the clean loop.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill First-Available Seat Booking 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Target reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

First-Available Seat Booking FAQ

How hard is the Target First-Available Seat Booking problem really?+

Very easy once you see it. There are no cancellations, so the lowest free seat is just a running counter. The difficulty is resisting the urge to build a data structure. If you write more than about six lines, you're overcomplicating it.

What's the trick to bookFirstAvailableSeats?+

Seats are never released, so assignments go 1, 2, 3 up to n in order. Track the next seat number. For each request, return it and increment if it's within n, otherwise return -1. No heap, set, or scanning needed.

What's the time complexity I should aim for?+

O(q) time. Each request does constant work: one comparison, one append, one increment. Space is O(q) for the result array. With q up to 100000, anything quadratic like scanning for a free seat each time is too slow.

Is this array pattern still asked in OAs like Target's?+

Yes. Simple simulation and counter problems wrapped in a business story show up regularly in screening rounds. The reported July 2026 Target version tests whether you can reduce a story to its core logic quickly, not whether you know advanced algorithms.

How do I prepare for this in 48 hours?+

Practice reducing wordy prompts to their invariants. Ask what changes between requests and what never does. Here, nothing frees up, so state is one integer. Write the loop, test n=1, test q greater than n, and check the -1 boundary. That covers it.

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

OA at Target?
Invisible during screen share
Get it