摘要:1. image filter : 项目描述: Image filtering allows you to apply various effects on photos. after open the app, customer can pick a image from Sd card ori...
阅读全文
摘要:无论所有题,一定要先分析清楚,所有eade case和逻辑都满足后,再动笔
阅读全文
摘要:http://www.youtube.com/watch?v=-6-xKgLOZPMbinary heap : it is a complete binary tree.index from 0:i left = 2i +1; i right = 2i +2, i parent = (i-1)/2....
阅读全文
摘要:http://www.youtube.com/watch?v=EdUWyka7kpI
阅读全文
摘要:1. using priortyqueue. priortyqueue是没有固定size的. http://wlh0706-163-com.iteye.com/blog/1850125 源码PriorityQueue(int initialCapacity, Comparator comparat...
阅读全文
摘要:http://www.youtube.com/watch?v=o3FUC6l89tMhttp://www.geeksforgeeks.org/counting-sort/only 0 - k can not be negtive71522 最大7.new array(7).0 1 2 3 4 5...
阅读全文
摘要:public interface Subject {public void registerObserver(Observer o);public void removeObserver(Observer o);public void notifyObservers();}public interf...
阅读全文
摘要:https://www.facebook.com/video/video.php?v=432864835468首先先看演讲. 太有营养了.1, trie .is straight forward, butwaste space, thrashes cache.1.points are huge.2....
阅读全文
摘要:insert sort:merge sort:其实很像后续遍历.package com.java2novice.sorting; public class MyMergeSort { private int[] array; private int[] tempMergArr;...
阅读全文
摘要:Find the deepest node in a binary tree:Example:A/ \B C/ \ / \D E F G\HReturn Node ‘H’public class test { //unsigned 2^32-1 so we need a long to ins...
阅读全文
摘要:bottom-uppackage test.ui;import java.util.HashSet;import java.util.Set;public class test { //unsigned 2^32-1 so we need a long to instead. pub...
阅读全文
摘要:/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; ...
阅读全文
摘要:456789101112131415161718192021// Return #nodes that matches P or Q in the subtree.int countMatchesPQ(Node *root, Node *p, Node *q) { if (!root) retur...
阅读全文
摘要:This is a very good linked list question, as there are tricky cases you have to consider, and getting them all right in one place is harder than it lo...
阅读全文
摘要:Brute force solution:Iterate 32 times, each time determining if the ith bit is a ’1′ or not. This is probably the easiest solution, and the interviewe...
阅读全文
摘要:BFS:Is it possible that a solution exists using only one single queue? Yes, you bet. The single queue solution requires two extra counting variables w...
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). How do you find an elemen...
阅读全文
摘要:April 13, 2010inUncategorizedRotate a one-dimensional array of n elements to the right by k steps.For instance, with n=7 and k=3, the array {a, b, c, ...
阅读全文
摘要:ProblemPrint a matrix in spiral fashion.SolutionWe will first print the periphery of the matrix by the help of 4 for loops. Then recursively call this...
阅读全文
摘要:Find the intersection of two sorted arrays.Let’s called array1 as A and array2 as B, each with size m and n.The obvious brute-force solution is to sca...
阅读全文
摘要:Write a class that displays average of stock prices for a given stock symbol for the last 10 minutes. We have a service that sends stock updates about...
阅读全文
摘要:Write a code to read and write a matrix in below given way.Note : no. indicates the sequence here.I/P1 2 34 5 67 8 9O/P 11 4 72 5 83 6 9for(i=0;i<row;...
阅读全文
摘要:Rand1*1 => uinformly distribution of 0,1 2Rand1*2 + Rand1 => 0,1,2,3 4Rand1*3 + Rand2 => 0,1,2,3,4,5 6Rand1*4 + Rand3 => 0,1,...
阅读全文
摘要:int rand7() //random number from 1 - 7{ int r = 0; do { int a = rand(5) - 1; //uniformly at random from 0 to 4 int b = rand(5) - ...
阅读全文
摘要:/*put all vaild new array from the 0 to new length*/public class Solution { public int removeDuplicates(int[] A) { if(A.length < 2) ...
阅读全文
摘要:int pp = 1; //number of points in the same line of the point i if (k.size()==0){pp=0;} for (int jj=1;jjres){res=pp...
阅读全文
摘要:计算所有的slope 放到一个arraylist中. 特殊情况是the same as point . 遍历所有./** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0)...
阅读全文
摘要:‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The matching should cover theentireinput string (not partial).The f...
阅读全文
摘要:N(n*m)的时间复杂度public class Solution {public String strStr(String haystack, String needle) { int nLen = needle.length(); int hLen = haystack.lengt...
阅读全文
摘要:一直对这种题比较没把握. 没有思路.i1,000,000.2234,333.999define valid(String s,boolean last,boolean first)1.先s.trim();if string==null or string.length==0 return false...
阅读全文
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric...
阅读全文
摘要:Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l...
阅读全文
摘要:首先呢 可能会想到用一个windows去放这些东西.可能会想到hashtable去. 但是hashtable 无法用Index去查询.abcabcbb. hashtable: abc 当第二个a来的时候, 我们想bca 貌似不好实现.这种情况就很像LRU. 用 node连接,用hashta...
阅读全文
摘要:http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html两种思路:top-down bottom-up递归实现,递归里面可以添加小递归方法. n^2自己总结的万能思路首先1. top-down 还...
阅读全文