Skip to content

Practice Airplane Seat Assignment Probability

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1227
LeetCode Problem

Airplane Seat Assignment Probability

Problem Statement

n passengers board in their assigned-seat order. The first chooses uniformly from all n seats after losing the ticket. Each later passenger takes their assigned seat if free, or chooses uniformly among remaining free seats if it is occupied. Return the probability that the final passenger sits in their own seat.

Source: Airplane Seat Assignment Probability on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 1
Output
1.00000

# Example 2

Input
n = 2
Output
0.50000

Constraints

1 <= n <= 10^5

Related LeetCode Problems

Practice more problems similar to Airplane Seat Assignment Probability.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.