Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, a ...
炎炎夏日,还是呆在空调房里切切题吧。 Container With Most Water,题意其实有点噱头,简化下就是,给一个数组,恩,就叫 height 吧,从中任选两项 i 和 j i lt j ,使得 Math.min height i , height j j i 最大化,求解这个最大值。 O n O n 复杂度的解法非常容易想到,直接两两枚举。 提交,TLE,看了下数据,数组长度 w,复 ...
2016-08-07 13:42 1 1722 推荐指数:
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, a ...
题目描述 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 注意 ...
一、题目说明 11.Container With Most Water,这个题目难度是Medium。 二、我的做法 乍一看,简单啊,两个for循环就可以了,我在本地写的。 提交后运行,居然Time Limit Exceeded是,好伤心。 里面给了一个非常长的数据,实际上我本地 ...
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
原题地址:https://oj.leetcode.com/problems/container-with-most-water/ 题意: Given n non-negative integers a1, a2, ..., an, where each represents a point ...
Container With Most Water 题目链接 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines ...
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai ...
题意是有个高度数组,就相当于隔板的高度,求数组中任意两隔板间盛水的最大量。隔板间的距离与较低隔板的高度乘积即为盛水的容量。 int maxArea(vector<int> &height) { int ...