You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><code data-stringify-type="code">n</code> passengers board an airplane with exactly <code data-stringify-type="code">n</code> seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will:</p>
<ul>
<li>Take their own seat if it is still available, </li>
<li>Pick other seats randomly when they find their seat occupied </li>
</ul>
<p>What is the probability that the n-th person can get his own seat?</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 1.00000
<strong>Explanation: </strong>The first person can only get the first seat.</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 0.50000
<strong>Explanation: </strong>The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).