Container With Most Water
来源:互联网 发布:playclubsaber捏脸数据 编辑:程序博客网 时间:2024/04/28 07:02
转http://www.cnblogs.com/codingmylife/archive/2012/09/05/2671548.html
题意是有个高度数组,就相当于隔板的高度,求数组中任意两隔板间盛水的最大量。隔板间的距离与较低隔板的高度乘积即为盛水的容量。
int maxArea(vector<int> &height) { int capability = 0; size_t left = 0, right = height.size() - 1; while (left < right) { const int water = min(height[left], height[right]) * (right - left); if (water > capability) capability = water; if (height[left] < height[right]) { ++left; } else { --right; } } return capability;}
- Container With Most Water
- Container with most water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Tutorial 09 - Interpolation
- 学习RatingBar的方法
- [XML学习笔记]001-XML概述、编写XML文档
- java面向对象特性(续)
- HDU 3007 Buried memory(点集最小圆覆盖 模拟退火解法)
- Container With Most Water
- 在windows 7 虚拟机上安装windows xp系统全过程总结
- 黑马程序员——浅谈java中的包
- 二叉树学习笔记
- InterlockedIncrement函数详解
- java抽象类和接口
- 数据结构.栈(C语言实现)
- 【XE5-IndyDB -2】 IndyDB 服务器
- UVa 10879 Code Refactoring (因数分解)