杭州做网站优化,活动策划网站,wordpress相册修改,小程序注册教程1、双指针 维护区间信息、子序列匹配、利用序列有序性、单项链表找环双指针 - OI Wiki (oi-wiki.org) 盛最多水的容器https://leetcode.cn/problems/container-with-most-water/ public class Solution {public int maxArea(int[] height) {int l 0, r height.length - 1;int…1、双指针 维护区间信息、子序列匹配、利用序列有序性、单项链表找环双指针 - OI Wiki (oi-wiki.org) 盛最多水的容器https://leetcode.cn/problems/container-with-most-water/ public class Solution {public int maxArea(int[] height) {int l 0, r height.length - 1;int ans 0;while (l r) {int area Math.min(height[l], height[r]) * (r - l);ans Math.max(ans, area);if (height[l] height[r]) {l;}else {--r;}}return ans;}
}2、前缀和
参见其他博客特殊数组—前缀和解法
3、数组模拟环