多城市二手车网站源码,wordpress高级自定义字段,代刷推广网站,滑动网站不懂的可以在评论区问我。
代码
双指针#xff0c;开始的时候一个在最左边#xff0c;一个在最右边。每次移动矮的那头#xff0c;因为这是矮柱子作为容器能装的水的极限了。
class Solution {
public:int maxArea(vectorint height) {int left 0; int rig…不懂的可以在评论区问我。
代码
双指针开始的时候一个在最左边一个在最右边。每次移动矮的那头因为这是矮柱子作为容器能装的水的极限了。
class Solution {
public:int maxArea(vectorint height) {int left 0; int right height.size()-1;int ans 0;while(leftright){ans max(ans, (right-left)*std::min(height[left], height[right]));if(height[left]height[right]) {left;}else{ right--;}}return ans;}
};