mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 14:58:56 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>有 <code>n</code> 个人排成一个队列,<strong>从左到右</strong> 编号为 <code>0</code> 到 <code>n - 1</code> 。给你以一个整数数组 <code>heights</code> ,每个整数 <strong>互不相同</strong>,<code>heights[i]</code> 表示第 <code>i</code> 个人的高度。</p>\n\n<p>一个人能 <strong>看到</strong> 他右边另一个人的条件是这两人之间的所有人都比他们两人 <strong>矮</strong> 。更正式的,第 <code>i</code> 个人能看到第 <code>j</code> 个人的条件是 <code>i < j</code> 且 <code>min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1])</code> 。</p>\n\n<p>请你返回一个长度为 <code>n</code> 的数组<em> </em><code>answer</code><em> </em>,其中<em> </em><code>answer[i]</code><em> </em>是第 <code>i</code> 个人在他右侧队列中能 <strong>看到</strong> 的 <strong>人数</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/05/29/queue-plane.jpg\" style=\"width: 600px; height: 247px;\" /></p>\n\n<pre>\n<b>输入:</b>heights = [10,6,8,5,11,9]\n<b>输出:</b>[3,1,2,1,1,0]\n<strong>解释:</strong>\n第 0 个人能看到编号为 1 ,2 和 4 的人。\n第 1 个人能看到编号为 2 的人。\n第 2 个人能看到编号为 3 和 4 的人。\n第 3 个人能看到编号为 4 的人。\n第 4 个人能看到编号为 5 的人。\n第 5 个人谁也看不到因为他右边没人。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>heights = [5,1,2,3,10]\n<b>输出:</b>[4,1,1,1,0]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == heights.length</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= heights[i] <= 10<sup>5</sup></code></li>\n\t<li><code>heights</code> 中所有数 <strong>互不相同</strong> 。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 26,
|
||||
"likes": 30,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -137,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.8K\", \"totalSubmission\": \"4.7K\", \"totalAcceptedRaw\": 2815, \"totalSubmissionRaw\": 4722, \"acRate\": \"59.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"3.1K\", \"totalSubmission\": \"5.1K\", \"totalAcceptedRaw\": 3098, \"totalSubmissionRaw\": 5141, \"acRate\": \"60.3%\"}",
|
||||
"hints": [
|
||||
"How to solve this problem in quadratic complexity ?",
|
||||
"For every subarray start at index i, keep finding new maximum values until a value larger than arr[i] is found.",
|
||||
|
||||
Reference in New Issue
Block a user