上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 36 下一页
摘要: 常用在线画图工具 https://www.geogebra.org/graphing https://www.cnblogs.com/henry-1202/p/10258867.html 阅读全文
posted @ 2023-10-26 10:22 爱新觉罗LQ 阅读(36) 评论(0) 推荐(0)
摘要: 从二维数组中截取连续行 int[][] temp = Arrays.copyOfRange(arr, 1, 2); // 截取第二行 阅读全文
posted @ 2023-10-25 23:55 爱新觉罗LQ 阅读(21) 评论(0) 推荐(0)
摘要: 组合公式 从m 个箱子中选出 n 个箱子 公式:\(C_{m}^{n}=\frac{m!}{n!(m-n)!)}\) 每种方式两两相邻球之间都有一个磁力,假设: 放置方式1的两两相邻球之间的磁力的最小值为a 放置方式2的两两相邻球之间的磁力的最小值为b ... 放置方式X的两两相邻球之间的磁力的最小 阅读全文
posted @ 2023-10-25 12:41 爱新觉罗LQ 阅读(55) 评论(0) 推荐(0)
摘要: KMP算法 1. 算法核心 利用匹配失败后的信息 尽量减少模式串(B)与主串(A)的匹配次数 以达到快速匹配的目的 通过一个 next 数组,保存模式串(B)中 前后最长公共子序列的长度,每次回溯时,通过 next 数组找到,前面匹配过的位置,省去了大量的计算时间 2. 如何减少匹配次数 2.1. 阅读全文
posted @ 2023-10-24 20:21 爱新觉罗LQ 阅读(29) 评论(0) 推荐(0)
摘要: 已知BST的前序遍历,还原BST arr数组:前序遍历 list:排序后的 arr 数组【BST的 中序遍历】 public static TreeNode getRoot(int[] arr, List<Integer> list){ int index = -1; for (int i = 0; 阅读全文
posted @ 2023-10-23 11:00 爱新觉罗LQ 阅读(28) 评论(0) 推荐(0)
摘要: 给定二叉树的前序遍历,遍历是否是 BST public static boolean isValid(int[] arr, int start, int end, int min, int max){ if (start > end){ // start > end:当前子树为空,返回 true,因 阅读全文
posted @ 2023-10-23 10:58 爱新觉罗LQ 阅读(24) 评论(0) 推荐(0)
摘要: 判断一个数是质数 public class PrimeNumberChecker { public static boolean isPrime(int number) { if (number <= 1) { return false; // 1和负数不是质数 } if (number <= 3) 阅读全文
posted @ 2023-10-20 16:48 爱新觉罗LQ 阅读(23) 评论(0) 推荐(0)
摘要: 互质数判断【空杯心态】 1 和任何其它都是互质数 相邻2个一定互质 2个不同的质数一定互质 欧几里德算法 通过递归计算两个数的最大公约数(GCD) 如果最大公约数为1,则说明两个数互质。 public static int gcd(int a, int b){ if (a == 0){ return 阅读全文
posted @ 2023-10-20 13:27 爱新觉罗LQ 阅读(41) 评论(0) 推荐(0)
摘要: 利用 Stream 流将 TreeSet 转成数组 Integer[] arr = set.stream().toArray(Integer[]::new); 阅读全文
posted @ 2023-10-20 11:23 爱新觉罗LQ 阅读(69) 评论(0) 推荐(0)
摘要: 整型数组逆序 由于 int型数组没有实现 comparator 接口,所以不支持逆序排序,所以我们建数组的时候就建成 Integer型就好了 Scanner in = new Scanner(System.in); int target = Integer.parseInt(in.nextLine( 阅读全文
posted @ 2023-10-18 11:49 爱新觉罗LQ 阅读(19) 评论(0) 推荐(0)
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 36 下一页