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>1</code> 到 <code>n</code> 编号排成一列。</p>\n\n<p>这座城市对这些新建筑有一些规定:</p>\n\n<ul>\n\t<li>每栋建筑的高度必须是一个非负整数。</li>\n\t<li>第一栋建筑的高度 <strong>必须</strong> 是 <code>0</code> 。</li>\n\t<li>任意两栋相邻建筑的高度差 <strong>不能超过</strong> <code>1</code> 。</li>\n</ul>\n\n<p>除此以外,某些建筑还有额外的最高高度限制。这些限制会以二维整数数组 <code>restrictions</code> 的形式给出,其中 <code>restrictions[i] = [id<sub>i</sub>, maxHeight<sub>i</sub>]</code> ,表示建筑 <code>id<sub>i</sub></code> 的高度 <strong>不能超过</strong> <code>maxHeight<sub>i</sub></code> 。</p>\n\n<p>题目保证每栋建筑在 <code>restrictions</code> 中<strong> 至多出现一次</strong> ,同时建筑 <code>1</code> <strong>不会</strong> 出现在 <code>restrictions</code> 中。</p>\n\n<p>请你返回 <strong>最高</strong> 建筑能达到的 <strong>最高高度</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/04/25/ic236-q4-ex1-1.png\" style=\"width: 400px; height: 253px;\" />\n<pre>\n<b>输入:</b>n = 5, restrictions = [[2,1],[4,1]]\n<b>输出:</b>2\n<b>解释:</b>上图中的绿色区域为每栋建筑被允许的最高高度。\n我们可以使建筑高度分别为 [0,1,2,1,2] ,最高建筑的高度为 2 。</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/04/25/ic236-q4-ex2.png\" style=\"width: 500px; height: 269px;\" />\n<pre>\n<b>输入:</b>n = 6, restrictions = []\n<b>输出:</b>5\n<b>解释:</b>上图中的绿色区域为每栋建筑被允许的最高高度。\n我们可以使建筑高度分别为 [0,1,2,3,4,5] ,最高建筑的高度为 5 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/04/25/ic236-q4-ex3.png\" style=\"width: 500px; height: 187px;\" />\n<pre>\n<b>输入:</b>n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]]\n<b>输出:</b>5\n<b>解释:</b>上图中的绿色区域为每栋建筑被允许的最高高度。\n我们可以使建筑高度分别为 [0,1,2,3,3,4,4,5,4,3] ,最高建筑的高度为 5 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 10<sup>9</sup></code></li>\n\t<li><code>0 <= restrictions.length <= min(n - 1, 10<sup>5</sup>)</code></li>\n\t<li><code>2 <= id<sub>i</sub> <= n</code></li>\n\t<li><code>id<sub>i</sub></code> 是 <strong>唯一的</strong> 。</li>\n\t<li><code>0 <= maxHeight<sub>i</sub> <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 33,
|
||||
"likes": 35,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"5.7K\", \"totalAcceptedRaw\": 2215, \"totalSubmissionRaw\": 5657, \"acRate\": \"39.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.3K\", \"totalSubmission\": \"5.7K\", \"totalAcceptedRaw\": 2254, \"totalSubmissionRaw\": 5738, \"acRate\": \"39.3%\"}",
|
||||
"hints": [
|
||||
"Is it possible to find the max height if given the height range of a particular building?",
|
||||
"You can find the height range of a restricted building by doing 2 passes from the left and right."
|
||||
|
Reference in New Issue
Block a user