算法
文章平均质量分 76
qq_27534691
这个作者很懒,什么都没留下…
展开
-
Leetcode算法题-分治
4. 寻找两个正序数组的中位数原创 2022-05-06 20:57:00 · 147 阅读 · 0 评论 -
Leetcode算法题-数学
166. 分数到小数https://leetcode-cn.com/problems/fraction-to-recurring-decimal/class Solution { public String fractionToDecimal(int numerator, int denominator) { if (numerator == 0) return "0"; StringBuilder fraction = new StringBuilder(原创 2020-10-24 10:36:55 · 75 阅读 · 0 评论 -
Leetcode算法题-动态规划
面试题 08.11. 硬币https://leetcode-cn.com/problems/coin-lcci/class Solution { public int waysToChange(int n) { int[] nums = {1,5,10,25}; long[][] dp = new long[5][n + 1]; for (int i = 0; i < 4; i++) { dp[i][0] = 1原创 2020-10-22 16:08:20 · 70 阅读 · 0 评论 -
Leetcode算法题-递归
面试题 08.06. 汉诺塔问题https://leetcode-cn.com/problems/hanota-lcci/class Solution { public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) { movePlat(A.size(), A, B, C); } public void movePlat(int sum, L原创 2020-10-21 11:27:20 · 69 阅读 · 0 评论 -
Leetcode算法题-回溯+深度和广度优先搜索
面试题 04.01. 节点间通路https://leetcode-cn.com/problems/route-between-nodes-lcci/class Solution { public boolean findWhetherExistsPath(int n, int[][] graph, int start, int target) { List<Integer>[] adj = new ArrayList[n]; for (int[]原创 2020-10-20 10:29:23 · 218 阅读 · 0 评论 -
Leetcode算法题-二叉树
124. 二叉树中的最大路径和https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/class Solution { int maxValue; public int maxPathSum(TreeNode root) { maxValue = Integer.MIN_VALUE; maxPathDown(root); return maxValue; }原创 2020-10-19 22:59:53 · 219 阅读 · 0 评论 -
Leetcode算法题-栈
面试题 03.01. 三合一https://leetcode-cn.com/problems/three-in-one-lcci/public class TripleInOne { //定义一个数组栈 private int[] stack; //定义一个头指针的数组 private int[] top; public TripleInOne(int stackSize) { //定义三栈合一 stack = new in原创 2020-10-19 19:32:53 · 164 阅读 · 0 评论 -
Leetcode算法题-位运算
201. 数字范围按位与https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/public int rangeBitwiseAnd(int m, int n) { int shift = 0; while (m < n) { m >>= 1; n >>= 1; shift++; }原创 2020-10-18 17:25:49 · 102 阅读 · 0 评论 -
Leetcode算法题-字符串
KMP算法public int[] getNext(String modelString) { int[] next = new int[modelString.length() + 1]; next[0] = -1; int i = 0, j = -1; while (i < modelString.length()) { if (j == -1 || modelString.charAt(i) == mo原创 2020-10-17 15:43:04 · 344 阅读 · 0 评论 -
Leetcode算法题-链表
19. 删除链表的倒数第N个节点https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/publicListNoderemoveNthFromEnd(ListNodehead,intn){ListNodedummy=newListNode(0);dummy.next=head;intlength=0;ListNodefirst=head;...原创 2020-10-17 13:00:08 · 220 阅读 · 0 评论 -
Leetcode算法题-数组
数组链表字符串动态规划树回溯算法深度优先搜索广度优先搜索哈希表栈和队列位运算排序并查集二分查找贪心算法原创 2020-10-17 11:11:37 · 436 阅读 · 0 评论