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
package history | |
import ( | |
"log" | |
"path" | |
"tstore/idgen" | |
"tstore/reliable" | |
"tstore/storage" | |
"tstore/types" |
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
package main | |
import ( | |
"fmt" | |
"golang.org/x/tour/tree" | |
) | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { |
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
class LRUCache { | |
private int capacity; | |
private int occupied; | |
private HashMap<Integer, Buffer> refs; | |
private Buffer head; | |
private Buffer tail; | |
public LRUCache(int capacity) { |
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
public class Solution { | |
/** | |
* @param stringArray: a string array | |
* @return: return every strings'short peifix | |
*/ | |
public String[] ShortPerfix(String[] stringArray) { | |
// write your code here | |
if (stringArray == null) { | |
return new String[]{}; | |
} |
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
class TrieNode { | |
boolean isWord; | |
HashMap<Character, TrieNode> children; | |
TrieNode() { | |
children = new HashMap<>(); | |
} | |
} | |
public class Trie { |
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
public class Solution { | |
/* | |
* @param A: An integer matrix | |
* @return: The index of the peak | |
*/ | |
public List<Integer> findPeakII(int[][] A) { | |
// write your code here | |
if (A == null || A.length < 3 || A[0].length < 3) { | |
return new LinkedList<>(); | |
} |
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
public class Solution { | |
/** | |
* @param str: the string | |
* @param dict: the dictionary | |
* @return: return words which are subsequences of the string | |
*/ | |
public List<String> findWords(String str, List<String> dict) { | |
// Write your code here. | |
List<String> words = new LinkedList<>(); | |
if (str == null || str.length() < 1 || dict == null || dict.size() < 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
public class Solution { | |
/** | |
* @param side_length: the length of a side of the lake (it's a square) | |
* @param lake_grid: a 2D matrix representing the lake 0= ice, 1= snowbank, -1= hole | |
* @param albert_row: row of Albert's snowbank | |
* @param albert_column: column of Albert's snowbank | |
* @param kuna_row: row of Kuna's snowbank | |
* @param kuna_column: column of Kuna's snowbank | |
* @return: a bool - whether Albert can escape | |
*/ |
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
class Solution { | |
public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) { | |
// write your code here | |
List<List<Integer>> bridges = new LinkedList<>(); | |
if (n < 1 || connections == null || connections.size() < 1) { | |
return bridges; | |
} | |
// 1. Create edge set | |
// 2. Build Graph |
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
class Solution { | |
public List<List<String>> accountsMerge(List<List<String>> accounts) { | |
List<List<String>> results = new ArrayList<>(); | |
if (accounts == null || accounts.size() < 1) { | |
return results; | |
} | |
HashMap<String, List<Integer>> emailToIds = mapEmailToIds(accounts); | |
UnionFind unionFind = linkAccounts(accounts, emailToIds); | |
HashMap<Integer, HashSet<String>> idToEmails = mapIdToEmails(accounts, unionFind); |
NewerOlder