摘要:
From Here Assume we have a binary tree below: _30_ / \ 10 20 / / \ 50 45 35Using pre-order traversal, the algorithm ... 阅读全文
摘要:
Given an array of numbers, nums, return an array of numbers products, where products[i] is the product of all nums[j], j != i. Input : [1... 阅读全文
摘要:
search for a target from a rotated sorted array non-recursion version from herepublic int search(int[] A, int target) { if(A==null || A.l... 阅读全文
摘要:
From Here /** * Given two nodes of a tree, * method should return the deepest common ancestor of those nodes. * * A ... 阅读全文
摘要:
/**This is for finding k nearest neighbor from the original pointusing a MAX heap, each time if the dist is less than the MAX we put it into t... 阅读全文
摘要:
From Here Changed it a littlepublic ArrayList> valid2(int[] A) { ArrayList> result = new ArrayList>(); Arrays.sort(A); fo... 阅读全文
摘要:
Just a BS(bulls**t) algorithm, nothing specialint binaryS (int[] array, int key, int min, int max) { if (max key) { return binaryS(... 阅读全文
摘要:
From Here Given a large network of computers, each keeping log files of visited urls, find the top ten most visited URLs.Ans: we will just mim... 阅读全文
摘要:
/** * Definition for undirected graph. * class UndirectedGraphNode { * int label; * List neighbors; * UndirectedGraphNode(int x) {... 阅读全文
摘要:
Given a binary tree, return the mirror of it. Very easy. RecursionTreeNode mirror(TreeNode root) { if (root == NULL) return NULL; else {... 阅读全文
摘要:
From Here 数学找规律public String getPermutation(int n, int k) { if(n nums = new ArrayList(); //initialize factorial for(int i=2;i=0) ... 阅读全文
摘要:
据说linkedin会考。。。没啥难的倒是public class Solution { public List> combinationSum2(int[] num, int target) { Arrays.sort(num); List> re... 阅读全文
摘要:
Implement a (Java) Iterable object that iterates lines one by one from a text file.. /** A reference to a file. */public class TextFile implem... 阅读全文
摘要:
From Here Given two (dictionary) words as Strings, determine if they are isomorphic.Two words are called isomorphic if the letters in one word... 阅读全文
摘要:
From HereLinkedin 的一道题目Keep track of the current remain factor to be decomposed, LargestFactor is the largest possible factor to decompose (s... 阅读全文
摘要:
Application layer shortening uses (original url => tiny url)expand url (tiny url => original url)Data Storage (hashtable tiny url’s hash code ... 阅读全文
摘要:
Code From Here (g4g)/**1) Initialize leftsum as 02) Get the total sum of the array as sum3) Iterate through the array and for each index i, d... 阅读全文
摘要:
print intersection of two sorted array 思路from g4g: 1) Use two index variables i and j, initial values i = 0, j = 0 2) If arr1[i] is smaller th... 阅读全文
摘要:
原帖地址:http://www.mitbbs.com/article_t/JobHunting/32909075.html 自己加了一点注释public static Iterable mergeKSortedIterators(List> Iters){ Queue ... 阅读全文
摘要:
From Here 这是一个带有upperbound的semaphore。public class BoundedSemaphore { private int signals = 0; private int bound = 0; public BoundedSemaph... 阅读全文