摘要:
回行打印二维数组 public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); 阅读全文
摘要:
快速幂带取余模版 a的b次方对num取余 算法思路: 例如求解275=264 * 28 * 22 * 21 可得 public long fastPower(long a, long b, long num) { long result = 1; while (b > 0) { if ((b & 1 阅读全文
摘要:
1.节点数据结构 public class Node { public int value; public Node left; public Node right; public Node(int data){ this.value = value; } } 2.递归 public class R 阅读全文
摘要:
KMP算法模版(左神的程序员代码面试指南第二版KMP算法) public class KMP { /** * @param s 匹配串 * @param m 模式串 * @return 匹配成功返回匹配串的匹配成功的字符串首个位置,匹配失败返回-1 */ public int getIndexOf( 阅读全文
摘要:
快速排序非递归算法(栈) import java.util.Stack; //快速排序非递归 public class Test { //使用栈保留左右两个边界,退出条件是左边界大于等于右边界 public static int[] quickSortUnRecur(int[] arr) { int 阅读全文
摘要:
题目:https://leetcode-cn.com/problems/range-sum-query-mutable/ 给定一个整数数组 nums,求出数组从索引 i 到 j (i ≤ j) 范围内元素的总和,包含 i, j 两点。 update(i, val) 函数可以通过将下标为 i 的数值更 阅读全文