11 2020 档案

摘要:##暴力 class Solution { //前缀和 public int minSubArrayLen(int s, int[] nums) { int n = nums.length; int res = n; //[i,j) int[] preSum = new int[n+1]; for( 阅读全文
posted @ 2020-11-10 21:20 浅滩浅 阅读(214) 评论(0) 推荐(0)
摘要:实际上就是c++中函数next_permutation的实现(包含重复元素) ##c++源码实现 网址:https://en.cppreference.com/w/cpp/algorithm/next_permutation template<class BidirIt> bool next_per 阅读全文
posted @ 2020-11-10 15:40 浅滩浅 阅读(198) 评论(0) 推荐(0)
摘要:##最粗暴的方法,自定义数据结构+重新定义排序规则 class Solution { public int[][] kClosest(int[][] points, int K) { int m = points.length; Node[] nodes = new Node[m]; for(int 阅读全文
posted @ 2020-11-09 16:04 浅滩浅 阅读(192) 评论(0) 推荐(0)
摘要:经典dfs将当前位置传入,标记和当前点一类的点,同时进行计数 class Solution { public int[] pondSizes(int[][] land) { List<Integer> res = new LinkedList<>(); int m = land.length,n = 阅读全文
posted @ 2020-11-08 20:10 浅滩浅 阅读(219) 评论(0) 推荐(0)
摘要:##错误代码 ##Arrays.sort(arr,(l,r)->l-r)后面自定义必须是类 ##正确代码 class Solution { public int[] sortByBits(int[] arr) { int n = arr.length; int[] res = new int[n]; 阅读全文
posted @ 2020-11-06 21:45 浅滩浅 阅读(224) 评论(0) 推荐(0)
摘要:思路:递增序列长度问题简化版 ##我的题解 class Solution { public boolean validMountainArray(int[] a) { int l = 0, r = 0; int aSize = a.length; //从左往右找以第一位元素开头的递增序列长度 for 阅读全文
posted @ 2020-11-03 19:33 浅滩浅 阅读(176) 评论(0) 推荐(0)