carloscn / carloscn/structstudy

leetcode11:盛最多水的容器(container-with-most-water)

Open
#65 2 comments 0 reactions 1 assignee Claimed by @carloscn View on GitHub
Level-middle 一般问题 数组 查找 贪心算法
Dominant language
C
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### 问题描述:

给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。

找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。

返回容器可以储存的最大水量。

说明:你不能倾斜容器。

示例 1:
![image](https://user-images.githubusercontent.com/16836611/202826835-d396f873-eeaa-4fca-a6bf-a3c3bf342340.png)
输入:[1,8,6,2,5,4,8,3,7]
输出:49
解释:图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。

示例 2:
输入:height = [1,1]
输出:1
 
提示:
n == height.length
2 <= n <= 105
0 <= height[i] <= 104

来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/container-with-most-water

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.