LeetCode 之 Container With Most Water
来源:互联网 发布:网络考试系统软件 编辑:程序博客网 时间:2024/06/06 21:15
题目链接:Container With Most Water
题意是给定n个非负整数a1, a2, a3, … ,an, 其中(i, a i)代表坐标上的一个点,过这个点向x轴作垂线,和x轴的交点为(i,0)。
需要找到两条线,其与x轴形成一个容器,使得容器包含最多的水,并返回容器的容量。
即找到ai,aj(i
class Solution { public int maxArea(int[] height) { int l = 0, r = height.length-1; int re = 0; while(l<r){ int vec = (r-l) * Math.min(height[l], height[r]); if(vec>re) re = vec; if(height[l]<height[r]) l++; else r--; } return re; }}
阅读全文
0 0
- LeetCode之Container With Most Water
- leetcode之Container With Most Water
- LeetCode之Container With Most Water
- 【Leetcode】之Container With Most Water
- LeetCode 之 Container With Most Water
- LeetCode之11---Container With Most Water
- Leetcode之Container With Most Water 问题
- LeetCode 之 Container With Most Water
- LeetCode: Container With Most Water
- [LeetCode]Container With Most Water
- LeetCode Container With Most Water
- LeetCode: Container With Most Water
- [Leetcode] Container With Most Water
- Leetcode: Container With Most Water
- [LeetCode] Container With Most Water
- LeetCode Container With Most Water
- [Leetcode] Container With Most Water
- [LeetCode]Container With Most Water
- ReactiveCocoa 的RACMulticastConnection使用
- 7.2 7.3 二叉树的概念和性质、存储
- 顺序队列(设计成环形队列)
- 动态代理学习笔记
- Linux ln -sf 的用法
- LeetCode 之 Container With Most Water
- poj 1050 To the Max
- 以cdn为前导,使用Nginx服务器反向代理,获取客户端真实ip的办法
- SSH框架整合(用户登录)
- Qt设置窗口不在系统的任务栏上显示
- 解决LINK : fatal error LNK1168: 无法打开 无法写入
- 最大二“货”
- 实战Linux Bluetooth编程(一) 协议栈概述
- C++中嵌套类的使用