1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-06 07:51:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-12-09 19:57:46 +08:00
parent 9bc4722a45
commit 3770b44d1e
4792 changed files with 10889 additions and 10886 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给定一个长度为 <code>n</code> 的整数数组&nbsp;<code>height</code>&nbsp;。有&nbsp;<code>n</code>&nbsp;条垂线,第 <code>i</code> 条线的两个端点是&nbsp;<code>(i, 0)</code>&nbsp;和&nbsp;<code>(i, height[i])</code>&nbsp;。</p>\n\n<p>找出其中的两条线,使得它们与&nbsp;<code>x</code>&nbsp;轴共同构成的容器可以容纳最多的水。</p>\n\n<p>返回容器可以储存的最大水量。</p>\n\n<p><strong>说明:</strong>你不能倾斜容器。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><img alt=\"\" src=\"https://aliyun-lc-upload.oss-cn-hangzhou.aliyuncs.com/aliyun-lc-upload/uploads/2018/07/25/question_11.jpg\" /></p>\n\n<pre>\n<strong>输入:</strong>[1,8,6,2,5,4,8,3,7]\n<strong>输出:</strong>49 \n<strong>解释:</strong>图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为&nbsp;49。</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>height = [1,1]\n<strong>输出:</strong>1\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == height.length</code></li>\n\t<li><code>2 &lt;= n &lt;= 10<sup>5</sup></code></li>\n\t<li><code>0 &lt;= height[i] &lt;= 10<sup>4</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 4729,
"likes": 4731,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Trapping Rain Water\", \"titleSlug\": \"trapping-rain-water\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u63a5\\u96e8\\u6c34\", \"isPaidOnly\": false}]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.1M\", \"totalSubmission\": \"1.9M\", \"totalAcceptedRaw\": 1133786, \"totalSubmissionRaw\": 1889614, \"acRate\": \"60.0%\"}",
"stats": "{\"totalAccepted\": \"1.1M\", \"totalSubmission\": \"1.9M\", \"totalAcceptedRaw\": 1134010, \"totalSubmissionRaw\": 1889977, \"acRate\": \"60.0%\"}",
"hints": [
"If you simulate the problem, it will be O(n^2) which is not efficient.",
"Try to use two-pointers. Set one pointer to the left and one to the right of the array. Always move the pointer that points to the lower line.",