mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 17:31:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>总计有 <code>n</code> 个环,环的颜色可以是红、绿、蓝中的一种。这些环分布穿在 10 根编号为 <code>0</code> 到 <code>9</code> 的杆上。</p>\n\n<p>给你一个长度为 <code>2n</code> 的字符串 <code>rings</code> ,表示这 <code>n</code> 个环在杆上的分布。<code>rings</code> 中每两个字符形成一个 <strong>颜色位置对</strong> ,用于描述每个环:</p>\n\n<ul>\n\t<li>第 <code>i</code> 对中的 <strong>第一个</strong> 字符表示第 <code>i</code> 个环的 <strong>颜色</strong>(<code>'R'</code>、<code>'G'</code>、<code>'B'</code>)。</li>\n\t<li>第 <code>i</code> 对中的 <strong>第二个</strong> 字符表示第 <code>i</code> 个环的 <strong>位置</strong>,也就是位于哪根杆上(<code>'0'</code> 到 <code>'9'</code>)。</li>\n</ul>\n\n<p>例如,<code>\"R3G2B1\"</code> 表示:共有 <code>n == 3</code> 个环,红色的环在编号为 3 的杆上,绿色的环在编号为 2 的杆上,蓝色的环在编号为 1 的杆上。</p>\n\n<p>找出所有集齐 <strong>全部三种颜色</strong> 环的杆,并返回这种杆的数量。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/11/23/ex1final.png\" style=\"width: 258px; height: 130px;\">\n<pre><strong>输入:</strong>rings = \"B0B6G0R6R0R6G9\"\n<strong>输出:</strong>1\n<strong>解释:</strong>\n- 编号 0 的杆上有 3 个环,集齐全部颜色:红、绿、蓝。\n- 编号 6 的杆上有 3 个环,但只有红、蓝两种颜色。\n- 编号 9 的杆上只有 1 个绿色环。\n因此,集齐全部三种颜色环的杆的数目为 1 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/11/23/ex2final.png\" style=\"width: 266px; height: 130px;\">\n<pre><strong>输入:</strong>rings = \"B0R0G0R9R0B0G0\"\n<strong>输出:</strong>1\n<strong>解释:</strong>\n- 编号 0 的杆上有 6 个环,集齐全部颜色:红、绿、蓝。\n- 编号 9 的杆上只有 1 个红色环。\n因此,集齐全部三种颜色环的杆的数目为 1 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><strong>输入:</strong>rings = \"G4\"\n<strong>输出:</strong>0\n<strong>解释:</strong>\n只给了一个环,因此,不存在集齐全部三种颜色环的杆。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>rings.length == 2 * n</code></li>\n\t<li><code>1 <= n <= 100</code></li>\n\t<li>如 <code>i</code> 是 <strong>偶数</strong> ,则 <code>rings[i]</code> 的值可以取 <code>'R'</code>、<code>'G'</code> 或 <code>'B'</code>(下标从 <strong>0</strong> 开始计数)</li>\n\t<li>如 <code>i</code> 是 <strong>奇数</strong> ,则 <code>rings[i]</code> 的值可以取 <code>'0'</code> 到 <code>'9'</code> 中的一个数字(下标从 <strong>0</strong> 开始计数)</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 12,
|
||||
"likes": 13,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"7.4K\", \"totalSubmission\": \"9.1K\", \"totalAcceptedRaw\": 7353, \"totalSubmissionRaw\": 9125, \"acRate\": \"80.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.4K\", \"totalSubmission\": \"9.2K\", \"totalAcceptedRaw\": 7368, \"totalSubmissionRaw\": 9157, \"acRate\": \"80.5%\"}",
|
||||
"hints": [
|
||||
"For every rod, look through ‘rings’ to see if the rod contains all colors.",
|
||||
"Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors."
|
||||
|
Reference in New Issue
Block a user