摘要: 题目链接 11. 盛最多水的容器 思路 在每个状态下,无论长板或短板向中间收窄一格,都会导致水槽底边宽度−1: 若向内移动短板,则 $min(h[i],h[j])$ 可能变大,因此下个水槽的面积可能增大 。 若向内移动长板,则 $min(h[i],h[j])$ 不变或变小,因此下个水槽的面积一定减小 阅读全文
posted @ 2023-01-30 19:25 Frodo1124 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 题目链接 18. 四数之和 思路 与 【双指针】LeetCode 15. 三数之和 思路相似,但是要注意测试用例可能溢出,需要转换为 long 代码 class Solution { public List<List<Integer>> fourSum(int[] nums, int target) 阅读全文
posted @ 2023-01-30 09:56 Frodo1124 阅读(11) 评论(0) 推荐(0) 编辑