FastPrepFirst-Available Seat Booking
Problems/First-Available Seat Booking

First-Available Seat Booking

Target logoTarget● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Target online assessment. The source defines giving out the first free seat with several callers at once, and what happens when seats run out. It does not give how seats are numbered, the order of requests, or the limits. Our version is about 90% the same as the reported question.

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 = 3q = 5return = [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 = 1q = 1return = [1]

The single request receives the only available seat.

Constraints

  • 1 <= n <= 100000.
  • 1 <= q <= 100000.

More Target Online Assessment questions

  • Count Lucky Numbers in a RangeOA · Seen Aug 2026
  • Minimum Edit-Distance String for Each QueryOA · Seen Aug 2026

Similar questions at other companies

  • First Successful Concurrent API Result Before a TimeoutApple · PHONE SCREENApple interview questions
  • Concurrent Discounted Card PurchasesBrex · PHONE SCREEN
  • Shared Counter Snapshot SumTesla · ONSITE INTERVIEWTesla interview questions
  • Circuit Breaker State MachineWise · ONSITE INTERVIEW
  • Schedule Buffered Video PlaybackNuro · PHONE SCREENNuro interview questions
  • Simulate a Queued Multi-Rule Rate LimiterSnowflake · PHONE SCREENSnowflake interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
See Target hiring insights
Saved
class Solution {
    public int[] bookFirstAvailableSeats(int n, int q) {
      // Write your code here.
    }
}
Checking account…