07 2021 档案

摘要:原题 797. 所有可能的路径 问题 最后 ans.add(path),但是此时传的是引用,path后面还会remove(),所以要复制一个path。 dfs(...){ if (...){ ans.add(new ArrayList<>(path))// 错误答案ans.add(path); re 阅读全文
posted @ 2021-07-27 22:47 acchris 阅读(24) 评论(0) 推荐(0)
摘要:List声明 List<E> list = new ArrayList<>(); E 指元素类型 List常见方法 返回类型 方法名 作用 boolean contains(Value) 列表中存在Value则返回true,否则false boolean add(Value) 添加进列表末尾 E g 阅读全文
posted @ 2021-07-07 20:44 acchris 阅读(46) 评论(0) 推荐(0)
摘要:使用lambda表达式 Collections.sort(List, (a,b) -> x1 - x2); 自定义Comparator方法 Collections.sort(List, new Comparator<E>(){ public int compare(int a, int b){ re 阅读全文
posted @ 2021-07-03 20:43 acchris 阅读(57) 评论(0) 推荐(0)
摘要:Collection接口 方法 boolean add(E obj) boolean addAll(Collection c) void clear() boolean isEmpty() Iterator iterator() boolean remove(Object obj) int size 阅读全文
posted @ 2021-07-03 20:27 acchris 阅读(49) 评论(0) 推荐(0)
摘要:TreeMap 与哈希表HashMap的区别: 有序表组织key,哈希表完全不组织。 **TreeMap关键点:**放入有序表中的元素,若不是基本类型,必须要有比较器,才能使其内部有序。 基本方法 Comparator<K> com = new Comparator<Integer>(){ @Ove 阅读全文
posted @ 2021-07-03 00:29 acchris 阅读(75) 评论(0) 推荐(0)