首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
装最多水的容器
[编程题]装最多水的容器
热度指数:16185
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给定n个非负整数a1,a2,…,an,其中每个数字表示坐标(i, ai)处的一个点。以(i,ai)和(i,0)(i=1,2,3...n)为端点画出n条直线。你可以从中选择两条线与x轴一起构成一个容器,最大的容器能装多少水?
注意:你不能倾斜容器
例如:
输入 [1,8,6,2,5,4,8,3,7]
输出: 49
示例1
输入
[1,8,6,2,5,4,8,3,7]
输出
49
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(95)
分享
提交结果有问题?
73个回答
2篇题解
开通博客
予辰
发表于 2020-07-09 21:46:46
题目描述给定n个非负整数a1,a2,…,an,其中每个数字表示坐标(i, ai)处的一个点。以(i,ai)和(i,0)(i=1,2,3...n)为端点画出n条直线。你可以从中选择两条线与x轴一起构成一个容器,最大的容器能装多少水?例如:输入 [1,8,6,2,5,4,8,3,7]输出: 49思路分析
展开全文
老北京2018
发表于 2021-05-26 15:13:52
方法1:暴力解法: class Solution { public: int maxArea(vector<int>& height) { int max = 0; for(int i =0; i<height.size();
展开全文
问题信息
数组
查找
难度:
73条回答
95收藏
26720浏览
热门推荐
通过挑战的用户
查看代码
偷鹿角的贼啊俄方我
2023-03-13 16:01:47
drakkko
2023-03-10 20:41:01
烦恼的哈士奇在打卡
2023-03-10 19:31:55
西乌乌乌乌乌、、
2023-03-08 18:23:47
许你在右的年华
2022-09-13 07:44:40
相关试题
执行以下程序,理论上输出的结果应最...
360集团
Python
算法工程师
2019
评论
(1)
来自
360公司-2019校招...
以下描述正确的是
Java
评论
(1)
以下对于随机森林算法描述错误的是:
机器学习
评论
(1)
生成数据集的随机子集
机器学习
评论
(1)
k近邻算法
机器学习
评论
(1)
装最多水的容器
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * * @param height int整型一维数组 * @return int整型 */ public int maxArea (int[] height) { // write code here } }
class Solution { public: /** * * @param height int整型vector * @return int整型 */ int maxArea(vector
& height) { // write code here } };
# # # @param height int整型一维数组 # @return int整型 # class Solution: def maxArea(self , height ): # write code here
/** * * @param height int整型一维数组 * @return int整型 */ function maxArea( height ) { // write code here } module.exports = { maxArea : maxArea };
# # # @param height int整型一维数组 # @return int整型 # class Solution: def maxArea(self , height ): # write code here
package main /** * * @param height int整型一维数组 * @return int整型 */ func maxArea( height []int ) int { // write code here }
[1,8,6,2,5,4,8,3,7]
49