[Leetcode] Container With Most Water
2015-09-18 15:31
330 查看
思路来自转载:
http://www.cnblogs.com/remlostime/archive/2012/10/29/2745018.html
http://www.cnblogs.com/remlostime/archive/2012/10/29/2745018.html
public static int maxArea(int[] height) { int max_area = 0; if (height == null || height.length <= 1) { return 0; } int left = 0; int right = height.length - 1; while (left < right) { int h = height[left] < height[right] ? height[left] : height[right]; int area = (right - left) * h; max_area = area > max_area ? area : max_area; if (height[left] > height[right]) { right--; } else { left++; } } return max_area; }
相关文章推荐
- Learning to rank的讲解,单文档方法(Pointwise),文档对方法(Pairwise),文档列表方法(Listwise)
- [Leetcode] 11 Container With Most Water
- Codeforces Round #319 (Div. 1)E.Painting Edges(并查集)
- Contains Duplicate II
- HDU 4819 Mosaic D区段树
- Contains Duplicate
- 添加第三方类库造成的linker command failed with exit code 1 (use -v to see invocation)的错误调试
- Magic Pairs - SGU 119(同余)
- 升级xcode7之后,真机调试出现BaiduMapAPI.framework/BaiduMapAPI(BMAddrList.o)' does n 4000 ot contain bitcode的问题
- INSTALL_FAILED_DUPLICATE_PERMISSION
- Contains Duplicate 重复数的判断
- 端口状态说明 LISTENING、ESTABLISHED、TIME_WAIT及CLOSE_WAIT
- SSH 错误解决案例1:Read from socket failed: Connection reset by peer
- grails Tags
- grails自定义标签
- grails检索mongodb
- 中国是大数据的人工智能的发源地
- codis扩容报错:[error] READONLY You can't write against a read only slave
- Error:(27, 42) 错误: <匿名com.jeff.networktest.MainActivity$1>不是抽象的, 并且未覆盖Handler中的抽象方法publish(LogRecord
- 纪念人工智能(AI)奠基60周年