Skip to content

Instantly share code, notes, and snippets.

View LeeReindeer's full-sized avatar
😶‍🌫️
Focusing

LeeR LeeReindeer

😶‍🌫️
Focusing
View GitHub Profile
@LeeReindeer
LeeReindeer / kthmax.c
Created April 17, 2019 12:21
Find k-th max
#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) {
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;
@LeeReindeer
LeeReindeer / banker.cc
Created December 31, 2018 08:53
Banker's Algorithm 银行家算法的简单实现
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
/**
* Banker's Algorithm by Dijkstra
*
* @author LeeR
*/
/*
@LeeReindeer
LeeReindeer / elevator.cc
Last active December 31, 2018 09:02
电梯调度算法 Elevator algorithm
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;
/**
* @brief 电梯调度算法
* @author LeeReindeer
* 试着模仿 ACM 竞赛题目的格式:
* 假设磁盘柱面编号由外向内递增,从0开始编号
@LeeReindeer
LeeReindeer / Test.java
Created December 18, 2018 02:09
Map implement by treap
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() {
@LeeReindeer
LeeReindeer / rsa.c
Last active May 20, 2018 08:28
Simple RSA Algorithm implement in C
/*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 {
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;