摘要:
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... 阅读全文
摘要:
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); }... 阅读全文