leetcode Container With Most Water python
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
""" intSum = len(height)
if intSum <= 1:
return False
maxVol=0
left=0
right=intSum-1
while left < right:
maxVol=max(maxVol,(right-left)*min(height[left],height[right]))
if height[left] < height[right]:
left+=1
else:
right-=1
return maxVol
leetcode Container With Most Water python的更多相关文章
- LeetCode:Container With Most Water,Trapping Rain Water
Container With Most Water 题目链接 Given n non-negative integers a1, a2, ..., an, where each represents ...
- [LeetCode] Container With Most Water 装最多水的容器
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- [LeetCode] Container With Most Water 简要分析
前言 这题非要说贪心的话也算是吧,不过最主要的特征还是双指针.LC的题好像不少都是扔倆头尾指针然后遍历一遍完事儿的.这道题倒是“短板效应”的不错体现了. 题目 题目链接 Given n non-neg ...
- [LeetCode]Container With Most Water, 解题报告
前言 难怪LeetCode OJ在找工作时被很多人推荐,发现了这道最大蓄水题目就是美团的笔试最后一道题,当时我霸笔只有着一道题目没有答出来,因此也就没有获得面试机会,可惜了 题目 Given n no ...
- C++LeetCode:: Container With Most Water
本来写的题目不是这个,而是字符串匹配,考虑了很多情况写了很久最后看了solution,发现可以用动态规划做.感觉被打击到了,果断先放着重新写一个题,后面心情好了再重新写吧,难过.每天都要被LeetCo ...
- leetcode Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- [Leetcode] Container With Most Water ( C++)
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- LeetCode——Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- LeetCode Container With Most Water (Two Pointers)
题意 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai ...
随机推荐
- sql 查询结果中加入空值列
select a,b,c,''d from X; 其中d为新加列,''表示默认值为空值 原文:http://hi.baidu.com/ddduggguo/item/747d5ba5ca18fd2689 ...
- .net通用权限框架B/S (五)--WEB(1)首页
通用权限框架--web 首页 1.首页截图 2.首页views 布局分为三部分top,left,main 引入easyui和jquery的js以及相关的css 使用easyui进行布局,分区代码bod ...
- Linux程序设计 读笔1
第一章 入门 Linux应用程表现为两种特殊类型文件:可执行文件 + 脚本文件 /bin 二进制文件目录,存放启动系统时用到的标准程序 /usr/bin 用户二进制文件目录,存放用户使用的标准程序 / ...
- echo向文件中写入
echo命令向一个文件写入内容的方法详解,感兴趣的朋友可以参考下. 覆盖型写法 (文件里原来的内容被覆盖)echo "aaa" > a.txtecho aaa > a. ...
- struts2表单提交的乱码的问题的解决
今天碰到一乱码问题,百思不得其解. 最后解决办法是设置了表单的提交方式,将method设置为post,解决问题.虽然默认的提交方式是post.但是如果不显式设置的话,就会出现我所出现的问题. 总结下处 ...
- 关于wireshark的两个抓包过滤显示的基本语法
关于wireshark的两个基本语法 关于wireshark的两个基本语法 1. Capture Filters 语法:<Protocol name><Direction>&l ...
- 通过 IP 访问谷歌
最近貌似谷歌都不能访问,对于我等经常使用谷歌的人说不是件好事,毕竟谷歌比百度专业,好在有解决办法: 1. 找到文件:C:\Windows\System32\drivers\etc\hosts 2. 把 ...
- composer时间长了,提示需要升级,结果问题来了
今天重新开始之前的laravel项目,结果composer提示需要升级,于是 composer selfupdate 结果提示无法连接目标库,查阅composer官网,发现之前的库地址已经启用了ssl ...
- javascript学习笔记(1) 简单html语法
<html> <head><meta http-equiv="content-type" content="text/html" ...
- java反射机制(笔记)
java反射机制就是获取出class的相应方法 例如 获取构造函数: 模版: Class test = Class.forName("cn.test.Person");//得到相应 ...