原创 堆排序

import java.util.Arrays; public class Test { private static void swap(int[] arr, int a, int b) { int tmp =

原创 二分查找

public class Main { /** * 查找第一個大於等於val的位置 * @param arr * @param val * @return */ priva

原创 複製含有隨機指針節點的鏈表

class Solution {     private static ListNode copyAndMerge(ListNode head) {         ListNode p = head;         ListNode

原创 用一個棧實現另一個棧的排序

import java.util.Objects; import java.util.Stack; class Solution {     private Stack<Integer> secondStack = new Stack

原创 最長遞增子序列

class Solution { private static int upperBound(int[] s, int len, int k) { int first = 0; while (len

原创 鏈表選擇排序

class Solution {     private static ListNode[] getAndRemoveTheSmallest(ListNode head) {         if (head == null) {   

原创 矩陣最小路徑和

public class Main {     private static int function(int[][] x) {         if (x == null || x.length == 0 || x[0].length 

原创 快速矩陣冪

/**  * @Author Tianyiya H.T.W  * @Date 2019/1/8 11:23  */ public class Main {     private static int[][] matrixPow(int

原创 快速冪

import java.util.Scanner; /**  * @Author Tianyiya H.T.W  * @Date 2019/1/8 11:23  */ public class Main {     private st

原创 貓狗隊列

class Pet {     private String type;     public Pet(String type) {         this.type = type;     }     public String 

原创 將單向鏈表按某值劃分成左邊小、中間相等、右邊大的形式

class Solution {     private static ListNode[] getArray(ListNode head) {         if (head == null) {             retur

原创 最長遞增子序列

class Solution { private static int upperBound(int[] s, int len, int k) { int first = 0; while (len

原创 基礎算法 - 二分查找

public class Main { private static int binary_search(int[] x, int key) { int l = 0, r = x.length - 1;

原创 矩陣最小路徑和

public class Main {     private static int function(int[][] x) {         if (x == null || x.length == 0 || x[0].length 

原创 快速冪

import java.util.Scanner; /**  * @Author Tianyiya H.T.W  * @Date 2019/1/8 11:23  */ public class Main {     private st