Skip to content

Instantly share code, notes, and snippets.

/*
* mergeTwoLists
* Returns the head of a sorted linked list, which is created by merging two sorted linked lists.
*
* @author Xiang Li <[email protected]>
* @param l1 the head of the first sorted linked list to be merged
* @param l2 the head of the second sorted linked list to be merged
* @return the head of the merged linked list
*
*
@shiangree
shiangree / Trie.java
Created October 9, 2015 02:31
Trie Implementation
package build;
import java.util.*;
public class Trie {
private int SIZE = 26;
private TrieNode root;
Trie()
{
root = new TrieNode();
}
private class TrieNode{
public class BlackJackCard extends Card {
public BlackJackCard(int c, Suit s) {
super(c, s);
}
public int value() {
if (isAce()) { // Ace
return 1;
} else if (faceValue >= 11 && faceValue <= 13) { // Face card
return 10;
@shiangree
shiangree / 4missing-bitSet.java
Last active January 30, 2018 06:00
Practices
//1,000,000 ints find 4 missing numbers
//naive way: bitset, using O(n) space
static List<Integer> findmissing(int[] array)
{
BitSet bset = new BitSet(array.length);
for(int i=0;i<array.length;++i)
{
bset.set(array[i]);