摘要:
等价于求最大元素和最小元素小于target的非空子集问题。 排序 双指针维护满足题意的最大窗口[i, j],方案数目:$2^$ 注意: 分析重复情况。 class Solution { public int numSubseq(int[] nums, int target) { int n = nu 阅读全文
摘要:
单调队列,维护合法窗口内的当前最大值(队头)及未来可能成为最大值的元素下标。 class Solution { public int findMaxValueOfEquation(int[][] p, int k) { int n = p.length; int res = Integer.MIN_ 阅读全文
摘要:
脑筋急转弯 每只蚂蚁都一样,相遇之后,相当于两人互换身份,继续朝原来的方向前进。因此,找出距离朝向端点最远的蚂蚁需要走多久,就是答案。 class Solution { public int getLastMoment(int n, int[] left, int[] right) { int re 阅读全文