摘要: DP.O(n) solution.对于每个bar,找出其左边与右边的最高高度, 可以hold的water =min(max_left, max_right) - height int trap(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int maxHeight = 0; vector left(n); for(int i=0;i right(n); for... 阅读全文
posted @ 2013-10-11 23:00 summer_zhou 阅读(142) 评论(0) 推荐(0) 编辑
摘要: int canCompleteCircuit(vector &gas, vector &cost) { // Note: The Solution object is instantiated only once and is reused by each test case. int tank = 0; int total = 0; int n = gas.size(); int index = -1; for(int i=0;i=0?index+1:-1); }... 阅读全文
posted @ 2013-10-11 22:01 summer_zhou 阅读(168) 评论(0) 推荐(0) 编辑