mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 07:21:40 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>有 <code>n</code> 位乘客即将登机,飞机正好有 <code>n</code> 个座位。第一位乘客的票丢了,他随便选了一个座位坐下。</p>\n\n<p>剩下的乘客将会:</p>\n\n<ul>\n\t<li>\n\t<p>如果他们自己的座位还空着,就坐到自己的座位上,</p>\n\t</li>\n\t<li>当他们自己的座位被占用时,随机选择其他座位</li>\n</ul>\n\n<p>第 <code>n</code> 位乘客坐在自己的座位上的概率是多少?</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 1\n<strong>输出:</strong>1.00000\n<strong>解释:</strong>第一个人只会坐在自己的位置上。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong> n = 2\n<strong>输出:</strong> 0.50000\n<strong>解释:</strong>在第一个人选好座位坐下后,第二个人坐在自己的座位上的概率是 0.5。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n <= 10^5</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 97,
|
||||
"likes": 100,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"11.4K\", \"totalSubmission\": \"17K\", \"totalAcceptedRaw\": 11365, \"totalSubmissionRaw\": 17018, \"acRate\": \"66.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"11.6K\", \"totalSubmission\": \"17.4K\", \"totalAcceptedRaw\": 11608, \"totalSubmissionRaw\": 17439, \"acRate\": \"66.6%\"}",
|
||||
"hints": [
|
||||
"Let f(n) denote the probability of the n-th person getting correct seat in n-person case, then:\r\n\r\nf(1) = 1 (base case, trivial)\r\nf(2) = 1/2 (also trivial)",
|
||||
"Try to calculate f(3), f(4), and f(5) using the base cases. What if the value of them?\r\nf(i) for i >= 2 will also be 1/2.",
|
||||
|
Reference in New Issue
Block a user