> For the complete documentation index, see [llms.txt](https://mayanktyagi3111.gitbook.io/interview-prep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mayanktyagi3111.gitbook.io/interview-prep/dynamic-programming/airplane-seat-assignment-probability.md).

# Airplane Seat Assignment Probability

`n` passengers board an airplane with exactly `n` seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will:

* Take their own seat if it is still available,&#x20;
* Pick other seats randomly when they find their seat occupied&#x20;

What is the probability that the n-th person can get his own seat?

**Example 1:**

```
Input: n = 1
Output: 1.00000
Explanation: The first person can only get the first seat.
```

**Example 2:**

```
Input: n = 2
Output: 0.50000
Explanation: The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).
```

**Constraints:**

* `1 <= n <= 10^5`

```java
class Solution {
    public double nthPersonGetsNthSeat(int n) {
        if(n==1)
            return 1;
        return 0.5;
    }
}
```
