mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 23:11:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>在一条无限长的公路上有 <code>n</code> 辆汽车正在行驶。汽车按从左到右的顺序按从 <code>0</code> 到 <code>n - 1</code> 编号,每辆车都在一个 <strong>独特的</strong> 位置。</p>\n\n<p>给你一个下标从 <strong>0</strong> 开始的字符串 <code>directions</code> ,长度为 <code>n</code> 。<code>directions[i]</code> 可以是 <code>'L'</code>、<code>'R'</code> 或 <code>'S'</code> 分别表示第 <code>i</code> 辆车是向 <strong>左</strong> 、向 <strong>右</strong> 或者 <strong>停留</strong> 在当前位置。每辆车移动时 <strong>速度相同</strong> 。</p>\n\n<p>碰撞次数可以按下述方式计算:</p>\n\n<ul>\n\t<li>当两辆移动方向 <strong>相反</strong> 的车相撞时,碰撞次数加 <code>2</code> 。</li>\n\t<li>当一辆移动的车和一辆静止的车相撞时,碰撞次数加 <code>1</code> 。</li>\n</ul>\n\n<p>碰撞发生后,涉及的车辆将无法继续移动并停留在碰撞位置。除此之外,汽车不能改变它们的状态或移动方向。</p>\n\n<p>返回在这条道路上发生的 <strong>碰撞总次数</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>directions = \"RLRSLL\"\n<strong>输出:</strong>5\n<strong>解释:</strong>\n将会在道路上发生的碰撞列出如下:\n- 车 0 和车 1 会互相碰撞。由于它们按相反方向移动,碰撞数量变为 0 + 2 = 2 。\n- 车 2 和车 3 会互相碰撞。由于 3 是静止的,碰撞数量变为 2 + 1 = 3 。\n- 车 3 和车 4 会互相碰撞。由于 3 是静止的,碰撞数量变为 3 + 1 = 4 。\n- 车 4 和车 5 会互相碰撞。在车 4 和车 3 碰撞之后,车 4 会待在碰撞位置,接着和车 5 碰撞。碰撞数量变为 4 + 1 = 5 。\n因此,将会在道路上发生的碰撞总次数是 5 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>directions = \"LLRR\"\n<strong>输出:</strong>0\n<strong>解释:</strong>\n不存在会发生碰撞的车辆。因此,将会在道路上发生的碰撞总次数是 0 。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= directions.length <= 10<sup>5</sup></code></li>\n\t<li><code>directions[i]</code> 的值为 <code>'L'</code>、<code>'R'</code> 或 <code>'S'</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 15,
|
||||
"likes": 17,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"7.2K\", \"totalSubmission\": \"18.9K\", \"totalAcceptedRaw\": 7208, \"totalSubmissionRaw\": 18861, \"acRate\": \"38.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.7K\", \"totalSubmission\": \"20.1K\", \"totalAcceptedRaw\": 7747, \"totalSubmissionRaw\": 20114, \"acRate\": \"38.5%\"}",
|
||||
"hints": [
|
||||
"In what circumstances does a moving car not collide with another car?",
|
||||
"If we disregard the moving cars that do not collide with another car, what does each moving car contribute to the answer?",
|
||||
|
Reference in New Issue
Block a user