Watch 10 video solutions for Airplane Seat Assignment Probability, a medium level problem involving Math, Dynamic Programming, Brainteaser. This walkthrough by NeetCode has 427,705 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
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 the passengers will:
Return the probability that the nth person gets 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 <= 105