上一页 1 2 3 4 5 6 7 8 9 ··· 33 下一页
摘要: 回行打印二维数组 public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); 阅读全文
posted @ 2020-04-24 00:26 All_just_for_fun 阅读(499) 评论(0) 推荐(0) 编辑
摘要: 斐波那契的状态矩阵,求解时间复杂度O(logN) 由f(n) = f(n-1) + f(n-2),f(n-1) = f(n-1) 得(f(n),f(n-1)) =(f(n-1) + f(n-2),f(n-1))得到关于(f(n-1),f(n-2))系数行列式,自底向上推出方程即可 得到(f(n),f 阅读全文
posted @ 2020-04-23 14:17 All_just_for_fun 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 大顶堆和小顶堆模版 //特殊情况可能出错:例如 Integer.MIN_VALUE - Integer.MAX_VALUE = 1 //大顶堆 PriorityQueue<Integer> maxHeapQueue = new PriorityQueue<>((o1, o2) -> o2 - o1) 阅读全文
posted @ 2020-04-23 13:19 All_just_for_fun 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 快速幂带取余模版 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 阅读全文
posted @ 2020-04-23 01:01 All_just_for_fun 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1.节点数据结构 public class Node { public int value; public Node left; public Node right; public Node(int data){ this.value = value; } } 2.递归 public class R 阅读全文
posted @ 2020-04-22 12:36 All_just_for_fun 阅读(290) 评论(0) 推荐(0) 编辑
摘要: KMP算法模版(左神的程序员代码面试指南第二版KMP算法) public class KMP { /** * @param s 匹配串 * @param m 模式串 * @return 匹配成功返回匹配串的匹配成功的字符串首个位置,匹配失败返回-1 */ public int getIndexOf( 阅读全文
posted @ 2020-04-19 01:08 All_just_for_fun 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 快速排序非递归算法(栈) import java.util.Stack; //快速排序非递归 public class Test { //使用栈保留左右两个边界,退出条件是左边界大于等于右边界 public static int[] quickSortUnRecur(int[] arr) { int 阅读全文
posted @ 2020-04-18 19:27 All_just_for_fun 阅读(462) 评论(0) 推荐(0) 编辑
摘要: 美团笔试题一共5题时间为2个小时 美团的题难度适中(相对于阿里),有简单的题,也有难题,都需要考虑一些特殊情况 第一题: 题目: 某学校的期末考试共有n个学生参加,考试科目共有m科。学校将会给一部分学生颁发单科成绩优秀奖,获奖学生需要满足的条件是某一科的成绩是所有学生中最高的或是最高的之一。请问学校 阅读全文
posted @ 2020-04-17 09:08 All_just_for_fun 阅读(1915) 评论(0) 推荐(1) 编辑
摘要: 1.Pair 在 import javafx.util.Pair; 包中,是一个简单的键值对类 2.Entry接口下的实现类 (1)SimpleEntry (2)SimpleImmutableEntry 此类不支持修改内容,一旦初始化后key和value就固定了,不能使用setValue方法修改 一 阅读全文
posted @ 2020-04-01 00:35 All_just_for_fun 阅读(7677) 评论(0) 推荐(1) 编辑
摘要: 题目:https://leetcode-cn.com/problems/range-sum-query-mutable/ 给定一个整数数组 nums,求出数组从索引 i 到 j (i ≤ j) 范围内元素的总和,包含 i, j 两点。 update(i, val) 函数可以通过将下标为 i 的数值更 阅读全文
posted @ 2020-03-31 19:18 All_just_for_fun 阅读(184) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 33 下一页