This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdio.h> | |
// Method 1 start | |
void exch(int *a, int i, int j) { | |
int t = a[i]; | |
a[i] = a[j]; | |
a[j] = t; | |
} | |
int partition(int *a, int lo, int hi) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Scanner; | |
/** | |
* @author leer | |
* Created at 3/15/19 8:19 PM | |
*/ | |
public class BinaryTree<T> { | |
public static class TreeNode<T> { | |
TreeNode left, right; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstring> | |
#include <iostream> | |
#include <set> | |
using namespace std; | |
/** | |
* Banker's Algorithm by Dijkstra | |
* | |
* @author LeeR | |
*/ | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cstdlib> | |
#include <iostream> | |
using namespace std; | |
/** | |
* @brief 电梯调度算法 | |
* @author LeeReindeer | |
* 试着模仿 ACM 竞赛题目的格式: | |
* 假设磁盘柱面编号由外向内递增,从0开始编号 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import java.util.TreeMap; | |
/** | |
* @author leer | |
* Created at 12/17/18 6:31 PM | |
*/ | |
public class Test { | |
@org.junit.Test | |
public void testTreap() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*see https://github.com/LeeReindeer/netwink/blob/master/dbg.h*/ | |
#include "../lib/dbg.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_DATA 1024 | |
#define LL long long | |
#define rsa_key_free free | |
typedef struct _key { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int nextID() { | |
try { | |
Number number = realm.where(object).max("id"); | |
if (number != null) { | |
return number.intValue() + 1; | |
} else { | |
return 0; | |
} | |
} catch (ArrayIndexOutOfBoundsException e) { | |
return 0; |