Tap here to switch tabs
Problem
Submissions

Problem: Airplane Seat Assignment Probability

Try to solve the Airplane Seat Assignment Probability problem.

Statement

There are n passengers boarding an airplane with exactly n seats. Each passenger has a ticket corresponding to a specific seat.

The first passenger loses their ticket and chooses a seat uniformly at random among all available seats. Every subsequent passenger boards the plane and will:

  • Sit in their assigned seat if it is still unoccupied.

  • Pick an unoccupied seat uniformly at random if their assigned seat has already been taken.

Return the probability that the nextthn^{ ext{th}} passenger obtains their assigned seat.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Airplane Seat Assignment Probability

Try to solve the Airplane Seat Assignment Probability problem.

Statement

There are n passengers boarding an airplane with exactly n seats. Each passenger has a ticket corresponding to a specific seat.

The first passenger loses their ticket and chooses a seat uniformly at random among all available seats. Every subsequent passenger boards the plane and will:

  • Sit in their assigned seat if it is still unoccupied.

  • Pick an unoccupied seat uniformly at random if their assigned seat has already been taken.

Return the probability that the nextthn^{ ext{th}} passenger obtains their assigned seat.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5