2021年8月23日
摘要: 【题目】 木桶短板,能装的最多水,由最短的那条决定 Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are dr 阅读全文
posted @ 2021-08-23 23:23 alau 阅读(52) 评论(0) 推荐(0)
摘要: 【整体思路】 先Arrays.sort()排序,不然后续指针没法用 对于K数之和,固定K-2个指针(循环),再用两指针一头一尾,根据sum大了小了,调左或调右 4数之和,2固定2移动; 3数之和,1固定2移动; 一定要记得去重,不仅为了减少工作量,也是确保输出结果的唯一 【题目】 leetcode1 阅读全文
posted @ 2021-08-23 22:39 alau 阅读(96) 评论(0) 推荐(0)
摘要: 【题目】 问每只兔子,有多少只和你颜色相同的(颜色问全了,不一定问道每只兔子),求这片森林中至少有多少只兔子 There is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have 阅读全文
posted @ 2021-08-23 19:09 alau 阅读(56) 评论(0) 推荐(0)
摘要: 【总结】 参考https://www.bilibili.com/video/BV1Pv4y1Z76N 适用情况:大部分需数组升序 【代码】 27 移除元素 不用管移除后半部分是否为正确答案,所以可直接nums[flag]=nums[i] class Solution { public int rem 阅读全文
posted @ 2021-08-23 16:52 alau 阅读(45) 评论(0) 推荐(0)
摘要: 【题目】 合并两个数组,两个数组已分别顺序排好,不能使用额外数组,就存在nums1中 You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, 阅读全文
posted @ 2021-08-23 11:23 alau 阅读(66) 评论(0) 推荐(0)