[LeetCode]Container With Most Water
发布日期:2021-11-22 02:48:56
浏览次数:6
分类:技术文章
本文共 731 字,大约阅读时间需要 2 分钟。
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
Note: You may not slant the container.
题解:从网上看到的,只知道left++,right--,表示不是很懂,没有证明。
public class Solution { public int maxArea(int[] height) { if(height == null || height.length ==1) return 0; int area =0,max = 0; int left = 0,right =height.length-1; while(leftheight[right]) right--; else left++; } return max; }}
转载地址:https://blog.csdn.net/zxdfc/article/details/48729253 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月01日 20时22分36秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
我的第一个MapReduce程序(WordCount)
2019-04-27
学习Hadoop时遇到的问题以及解决方法
2019-04-27
Http Chunked Transfer Coding
2019-04-27
本人使用Intelij idea问题及解决汇总
2019-04-27
IntelliJ IDEA WEB项目的部署配置
2019-04-27
Mybatis传多个参数(三种解决方案)
2019-04-27
使用(x&y) + ((x^y)>>1) 求平均数
2019-04-27
关于负数的补码
2019-04-27
java位运算应用
2019-04-27
大数相乘--极简单的思路
2019-04-27
Intelij IDEA注册码生成代码
2019-04-27
静态内部类和非静态内部类区别汇总
2019-04-27
数据结构与算法
2019-04-27
设计模式
2019-04-27
java实现排序二叉树
2019-04-27
openSUSE中文输入的安装和设置
2019-04-27
OpenSUSE 系统安装无线网卡驱动。
2019-04-27
Android activity的生命周期
2019-04-27
Java内存模型
2019-04-27
指令重排序
2019-04-27