mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 08:21:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个细长的画,用数轴表示。这幅画由若干有重叠的线段表示,每个线段有 <strong>独一无二</strong> 的颜色。给你二维整数数组 <code>segments</code> ,其中 <code>segments[i] = [start<sub>i</sub>, end<sub>i</sub>, color<sub>i</sub>]</code> 表示线段为 <strong>半开区间</strong> <code>[start<sub>i</sub>, end<sub>i</sub>)</code> 且颜色为 <code>color<sub>i</sub></code> 。</p>\n\n<p>线段间重叠部分的颜色会被 <strong>混合</strong> 。如果有两种或者更多颜色混合时,它们会形成一种新的颜色,用一个 <strong>集合</strong> 表示这个混合颜色。</p>\n\n<ul>\n\t<li>比方说,如果颜色 <code>2</code> ,<code>4</code> 和 <code>6</code> 被混合,那么结果颜色为 <code>{2,4,6}</code> 。</li>\n</ul>\n\n<p>为了简化题目,你不需要输出整个集合,只需要用集合中所有元素的 <strong>和</strong> 来表示颜色集合。</p>\n\n<p>你想要用 <strong>最少数目</strong> 不重叠 <strong>半开区间</strong> 来 <b>表示</b> 这幅混合颜色的画。这些线段可以用二维数组 <code>painting</code> 表示,其中 <code>painting[j] = [left<sub>j</sub>, right<sub>j</sub>, mix<sub>j</sub>]</code> 表示一个 <strong>半开区间</strong><code>[left<sub>j</sub>, right<sub>j</sub>)</code> 的颜色 <strong>和</strong> 为 <code>mix<sub>j</sub></code> 。</p>\n\n<ul>\n\t<li>比方说,这幅画由 <code>segments = [[1,4,5],[1,7,7]]</code> 组成,那么它可以表示为 <code>painting = [[1,4,12],[4,7,7]]</code> ,因为:\n\n\t<ul>\n\t\t<li><code>[1,4)</code> 由颜色 <code>{5,7}</code> 组成(和为 <code>12</code>),分别来自第一个线段和第二个线段。</li>\n\t\t<li><code>[4,7)</code> 由颜色 <code>{7}</code> 组成,来自第二个线段。</li>\n\t</ul>\n\t</li>\n</ul>\n\n<p>请你返回二维数组 <code>painting</code> ,它表示最终绘画的结果(<strong>没有</strong> 被涂色的部分不出现在结果中)。你可以按 <strong>任意顺序</strong> 返回最终数组的结果。</p>\n\n<p><strong>半开区间 </strong><code>[a, b)</code> 是数轴上点 <code>a</code> 和点 <code>b</code> 之间的部分,<strong>包含 </strong>点 <code>a</code> 且 <strong>不包含</strong> 点 <code>b</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/06/18/1.png\" style=\"width: 529px; height: 241px;\">\n<pre><b>输入:</b>segments = [[1,4,5],[4,7,7],[1,7,9]]\n<b>输出:</b>[[1,4,14],[4,7,16]]\n<strong>解释:</strong>绘画借故偶可以表示为:\n- [1,4) 颜色为 {5,9} (和为 14),分别来自第一和第二个线段。\n- [4,7) 颜色为 {7,9} (和为 16),分别来自第二和第三个线段。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/06/18/2.png\" style=\"width: 532px; height: 219px;\">\n<pre><b>输入:</b>segments = [[1,7,9],[6,8,15],[8,10,7]]\n<b>输出:</b>[[1,6,9],[6,7,24],[7,8,15],[8,10,7]]\n<b>解释:</b>绘画结果可以以表示为:\n- [1,6) 颜色为 9 ,来自第一个线段。\n- [6,7) 颜色为 {9,15} (和为 24),来自第一和第二个线段。\n- [7,8) 颜色为 15 ,来自第二个线段。\n- [8,10) 颜色为 7 ,来自第三个线段。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/04/c1.png\" style=\"width: 529px; height: 289px;\">\n<pre><b>输入:</b>segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]\n<b>输出:</b>[[1,4,12],[4,7,12]]\n<strong>解释:</strong>绘画结果可以表示为:\n- [1,4) 颜色为 {5,7} (和为 12),分别来自第一和第二个线段。\n- [4,7) 颜色为 {1,11} (和为 12),分别来自第三和第四个线段。\n注意,只返回一个单独的线段 [1,7) 是不正确的,因为混合颜色的集合不相同。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= segments.length <= 2 * 10<sup>4</sup></code></li>\n\t<li><code>segments[i].length == 3</code></li>\n\t<li><code>1 <= start<sub>i</sub> < end<sub>i</sub> <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= color<sub>i</sub> <= 10<sup>9</sup></code></li>\n\t<li>每种颜色 <code>color<sub>i</sub></code> 互不相同。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 14,
|
||||
"likes": 15,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -131,7 +131,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.3K\", \"totalSubmission\": \"5.5K\", \"totalAcceptedRaw\": 2286, \"totalSubmissionRaw\": 5461, \"acRate\": \"41.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.3K\", \"totalSubmission\": \"5.5K\", \"totalAcceptedRaw\": 2316, \"totalSubmissionRaw\": 5518, \"acRate\": \"42.0%\"}",
|
||||
"hints": [
|
||||
"Can we sort the segments in a way to help solve the problem?",
|
||||
"How can we dynamically keep track of the sum of the current segment(s)?"
|
||||
|
Reference in New Issue
Block a user