Skip to content

Instantly share code, notes, and snippets.

View junminstorage's full-sized avatar

Junmin Liu junminstorage

View GitHub Profile
Given a list of tasks with execution time of each task and its dependecies.
e.g.
A, 2 <== task A needs 2 timeunits to finish
B, 3 <== taks B needs 3 timeunits to finish
C, 5
D, 3
B, C can run only after A finishes. D can run only after B finished.
A -> B,C
B -> D
Let's say we label each person starting with index 0, for N persons, we have
0, 1, 2, 3, ...., N-1.
Fn(N, K) return the index of the last person, with starting position at 0
Given N persons, after removing the Kth person, then the next starting position will be K%N
Fn(N-1, K) return the position of the survivor with starting position at 0 then for starting position of K%N
(Fn(N-1, K) + K)%N will return the position of the survivor.
 Contributed to design and full stack development of SIM card distributing system which performs card resource allocation to business units. Developed its both client-facing and adminstrator UI using React/Typescript, its backend RESTful services using Spring Boot/SpringMVC/MyBatis ORM library.
 Stored data into MySQL cluster, configure its cross-datacenter master-slave replication and synchronization.
 Developed user-friendly and responsive mobile UI using HTML5 and SUI mobile library.
 Deployed the application to the distributed web service on Alibaba Cloud ECS
Typo:
Elastic Search -. Elasticsearch
Questionable statement:
Managed data synchronization by delivering MySQL Binlog changes in full-text index for data analysis by providing
List<int[]> list = new ArrayList<>();
list.add(new int[]{1, 2});
list.add(new int[]{2, 3});
int[][] re = list.toArray(new int[2][0]); //THIS MAY HAVE BUG IF list.size is not 2
private void bfs(char[][] board, int row, int col) {
Deque<int[]> q = new ArrayDeque<>();
q.offer(new int[] { row, col });
board[row][col] = '*';
while (!q.isEmpty()) {
int[] cell = q.poll();
int r = cell[0], c = cell[1];
for (int[] dir : dirs) {
if (r + dir[0] >= 0 && r + dir[0] < rows && c + dir[1] >= 0 && c + dir[1] < cols
class State {
int pos;
int speed;
String instr;
State(int p, int s, String str) {
pos = p; speed = s; instr = str;
}
public int hashCode() {
return pos*31 + speed + 31*31;
}
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
Examples:
Input: arr[] = {2, 0, 2}
Output: 2
Structure is like below
| |
|_|
We can trap 2 units of water in the middle gap.
public List<List<String>> findLadders(String start, String end, List<String> wordList) {
Set<String> dict = new HashSet<>();
for(String w : wordList)
dict.add(w);
int len = start.length();
Set<String> visited = new HashSet<>();
Set<String> queue = new HashSet<>();
queue.add(start);
@junminstorage
junminstorage / gist:b996ad04a9daff03127ffd719411e9f3
Created March 14, 2020 13:38
given a number, we can either reduce it by 1 or divided by 2 or 3, find the minimum step to reach 1 from any given number
static Map<Integer, Integer> store = new HashMap<>();
static public int dfs(int current) {
if(current == 1)
return 0;
if(store.containsKey(current))
return store.get(current);
int min = dfs(current-1) + 1;
if(current%2==0)
static interface Excel {
void put(String cell, Integer value, String formula);
int get(String cell);
}
static class CellNode {
String cell;
String formula;
int value;