1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/盛最多水的容器 [container-with-most-water].html
2022-03-29 12:43:11 +08:00

36 lines
1.3 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>
<p>找出其中的两条线,使得它们与&nbsp;<code>x</code>&nbsp;轴共同构成的容器可以容纳最多的水。</p>
<p>返回容器可以储存的最大水量。</p>
<p><strong>说明:</strong>你不能倾斜容器。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://aliyun-lc-upload.oss-cn-hangzhou.aliyuncs.com/aliyun-lc-upload/uploads/2018/07/25/question_11.jpg" /></p>
<pre>
<strong>输入:</strong>[1,8,6,2,5,4,8,3,7]
<strong>输出:</strong>49
<strong>解释:</strong>图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为&nbsp;49。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>height = [1,1]
<strong>输出:</strong>1
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == height.length</code></li>
<li><code>2 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= height[i] &lt;= 10<sup>4</sup></code></li>
</ul>