摘要: 等价于求最大元素和最小元素小于target的非空子集问题。 排序 双指针维护满足题意的最大窗口[i, j],方案数目:$2^$ 注意: 分析重复情况。 class Solution { public int numSubseq(int[] nums, int target) { int n = nu 阅读全文
posted @ 2020-07-14 18:48 li修远 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 单调队列,维护合法窗口内的当前最大值(队头)及未来可能成为最大值的元素下标。 class Solution { public int findMaxValueOfEquation(int[][] p, int k) { int n = p.length; int res = Integer.MIN_ 阅读全文
posted @ 2020-07-14 18:31 li修远 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 将每个数按照mod k的余数不同分成k类, 负数的余数为负数,特殊处理:(arr[i] % k + k) % k。 class Solution { public boolean canArrange(int[] arr, int k) { int[] cnt = new int[k]; for(i 阅读全文
posted @ 2020-07-14 11:37 li修远 阅读(106) 评论(0) 推荐(0) 编辑