上一页 1 2 3 4 5 6 ··· 13 下一页
摘要: 传送门 代码 class CQueue { Stack<Integer> stack1; Stack<Integer> stack2; public CQueue() { stack1 = new Stack<>(); stack2 = new Stack<>(); } public void ap 阅读全文
posted @ 2021-01-01 19:24 lukelmouse 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 传送门 代码 class Solution { private int ans = 1; public int diameterOfBinaryTree(TreeNode root) { dfs(root); return ans - 1; } public int dfs(TreeNode roo 阅读全文
posted @ 2021-01-01 19:20 lukelmouse 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 传送门 代码 class Solution { public List<List<Integer>> levelOrderBottom(TreeNode root) { List<List<Integer>> ans = new LinkedList<>(); if(root == null) re 阅读全文
posted @ 2021-01-01 19:12 lukelmouse 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 传送门 代码 class Solution { public int lengthOfLongestSubstring(String s) { Set<Character> set = new HashSet<>(); int ans = 0,n = s.length(); for(int r = 阅读全文
posted @ 2020-12-14 12:51 lukelmouse 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 传送门 代码 class Solution { public int findKthLargest(int[] nums, int k) { return quickSelect(nums,0,nums.length - 1,nums.length - k); } public int quickS 阅读全文
posted @ 2020-12-13 14:00 lukelmouse 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 传送门 代码 class Solution { public ListNode reverseList(ListNode head) { ListNode cur = head,pre = null; while(cur != null) { ListNode tmp = cur.next; cur 阅读全文
posted @ 2020-12-13 13:20 lukelmouse 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 快速排序 时间复杂度:\(O(n\log n)\) 空间复杂度:\(O(\log n)\) 不稳定 public static void sortQuick(int[] arr,int l,int r) { if(l >= r) return; int base = arr[l + r >> 1]; 阅读全文
posted @ 2020-12-03 19:58 lukelmouse 阅读(75) 评论(3) 推荐(0) 编辑
摘要: C 问题描述 初始状态给你一个 $1$,有两种操作 给其中一个数字增加 1 复制其中一个数字并添加到该序列中 问你最少要几次操作,才能得到数字 \(n\) 题解 tag:贪心,枚举 对于两个操作来说,肯定是 先 \(+1\) 再复制,得到的数字更大,(因为这个$+1$ 操作被复制成了两份), 否则我 阅读全文
posted @ 2020-09-30 00:31 lukelmouse 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 对于这种式子$f(l,r)=(\sum_^a_i)\times w_{r-l+1}$ 一般情况下,我们先仿照答案写出前几项,看看有没有规律 定义前缀和 \(s_k=\sum_{i=1}^{k}a_i\) ,把要求出的式子$\sum_\sum_f(l,r)$展开来写 \[ \begin{aligned 阅读全文
posted @ 2020-07-20 23:15 lukelmouse 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 因为这类问题都需要从前一步来推后一步,所以大概率是DP类问题 首先我们需要确定状态,如果把每种颜色都当成一维来记录的话,最大是$15$ 维肯定是不可取的,所以就要考虑别的状态 因为每种颜色$c_i\leq5$ ,我们可以把每种颜色剩余能涂的个数看成一个等价类 来确定每种状态 \(f[c1][c2][ 阅读全文
posted @ 2020-07-19 16:00 lukelmouse 阅读(132) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 13 下一页