LeetCode 11. 盛最多水的容器

时间:2022-07-23
本文章向大家介绍LeetCode 11. 盛最多水的容器,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

A

11. 盛最多水的容器

/**
 * [11. 盛最多水的容器](https://leetcode-cn.com/problems/container-with-most-water/)
 * 一个非负数组。寻找两个坐标,能构成最大面积水池。
 * 输入:[1,8,6,2,5,4,8,3,7] 
 * 输出:49
 * 方法1:双遍历,x从0开始,y从x+1开始,求面积 (y - x) * height_diff。O(n^2^)
 * 方法2:两边夹逼,取高度低的那个往里挪。O(n)
 */
class Solution {
    public int maxArea(int[] a) {
        int max = 0;
        for (int i = 0, j = a.length - 1; i < j; ) {
            int minH = a[i] < a[j] ? a[i++] : a[j--];
            max = Math.max(max, (j - i + 1) * minH);
        }
        return max;
    }
}

R

https://frenxi.com/http-headers-you-dont-expect/

最酷的互联网公司现在把招聘信息放在了HTTP请求头x-recruiting里面

T

《数据结构与算法之美》笔记

S

新版IntelliJ IDEA的更新

https://blog.csdn.net/weixin_43413658/article/details/105839472

微信定时提醒应用

https://blog.betacat.io/post/how-wecron-schedules/

LeetCode前300题

https://leetcode.wang/