This file contains hidden or 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
-- create table | |
CREATE TABLE `idempotence_keys` ( | |
`id` bigint(20) NOT NULL AUTO_INCREMENT, | |
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`), | |
KEY `created_at` (`created_at`) | |
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC | |
-- insert | |
insert into idempotence_keys (created_at) |
This file contains hidden or 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.Arrays; | |
import java.util.List; | |
/** | |
* Created by pyq on 11/24/16. | |
*/ | |
/* | |
We have an array of Integers. We want to reorder the elements in-place to have even numbers as far from each other as possible (i.e. we want to maximize the minimum distance between any two even numbers in the list). Note that we do not want to create a second array, and would like this to happen in the original array, in-place. | |
For example: |
This file contains hidden or 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.*; | |
/** | |
* Created by pyq on 11/16/16. | |
* Question 4 | |
========== | |
1 | |
2 5 | |
3 2 1 | |
1 3 2 1 |
This file contains hidden or 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.io.EOFException; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.util.IllegalFormatException; | |
/** | |
* Created by yongqingpeng on 7/15/16. | |
*/ | |
class SuperClass | |
{ |
This file contains hidden or 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.io.EOFException; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.util.IllegalFormatException; | |
/** | |
* Created by yongqingpeng on 7/15/16. | |
*/ | |
class SuperClass | |
{ |
This file contains hidden or 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.Collection; | |
import java.util.Collections; | |
import java.util.Iterator; | |
/** | |
* Created by pyq on 5/6/15. | |
*/ | |
/* |
This file contains hidden or 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.lang.reflect.Array; | |
import java.util.*; | |
/** | |
* Created by pyq on 4/10/15. | |
*/ | |
public class Ticket { | |
// has n stations, every station has stations[i] number tickets, and sell with station[i] price | |
// public static long maxProfit(int[] stations, int n, int m) { | |
// Queue<Integer> maxHeap = new PriorityQueue<>(n, new Comparator<Integer>(){ |
This file contains hidden or 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 sys | |
import random | |
no_of_heaps = random.choice([3,5,7]) | |
heap = [] | |
user = random.choice([0,1]) # if "user" is assigned value 0, then computer goes first, else vice versa | |
nextMove = '' | |
def gameInitialSetup(): | |
for x in range(no_of_heaps): |