There are n passengers and n seats on a plane.
The first passenger has lost their seat assignment, so they choose a seat at random.
Each following passenger:
Sits in their own seat if it is still available.
Otherwise, they randomly choose one of the remaining seats.
You must determine the probability that the nth (last) passenger ends up sitting in their correct seat.
Input: n = 1
Output: 1.0
Explanation:
With only one passenger, they obviously take their own seat.
Input: n = 3
Output: 0.5
Explanation:
The third passenger has a 50% chance to keep their seat.
Accepted:
Submission: