11 2015 档案

摘要:reference: Java DocWhat is ExceptionException is short for "exceptional event".When an error occurs within a method, the method creates an object and ... 阅读全文
posted @ 2015-11-10 12:45 树獭君 阅读(475) 评论(0) 推荐(0)
摘要:Separate Chaining Use data structure (such as linked list) to store multiple items that hash to the same slot 1. use linked listCollision: insert item 阅读全文
posted @ 2015-11-10 01:37 树獭君 阅读(262) 评论(0) 推荐(0)
摘要:Reference: WikiPrincetonAlgorithmWhat is Hash TableHash table (hash map) is a data structure used to implement an associative array, a structure that ... 阅读全文
posted @ 2015-11-10 01:37 树獭君 阅读(485) 评论(0) 推荐(0)
摘要:参考Java的官方tutorial和Doc整理如下。What is EnumAn enum type is a special data type.It enablesfor a variable to be a set of predefined constants.Because they ar... 阅读全文
posted @ 2015-11-09 23:31 树獭君 阅读(246) 评论(0) 推荐(0)
摘要:In Java, a method signature is the method name and the number and type of its parameters. Return types and thrown exceptions are not considered to be ... 阅读全文
posted @ 2015-11-09 22:48 树獭君 阅读(248) 评论(0) 推荐(0)
摘要:Reference: JavaPointBeginnerBookWhat is BindingConnecting a method call to the method body is known as binding.There are two types of bindingstatic bi... 阅读全文
posted @ 2015-11-09 22:47 树獭君 阅读(399) 评论(0) 推荐(1)
摘要:阅读Java的官方Doc,总结如下。What is InterfaceAn interface is a reference type, similar to a class, that can contain onlyconstants (implicitly public, static, fi... 阅读全文
posted @ 2015-11-09 12:48 树獭君 阅读(424) 评论(0) 推荐(0)
摘要:阅读了Java的官方Doc,在此总结如下。Abstract Class & MethodIn jave, "abstract" can be a modifier to class and method.Abstract class:A class that is declared abstract... 阅读全文
posted @ 2015-11-09 12:12 树獭君 阅读(285) 评论(0) 推荐(0)
摘要:QuestionWrite a program to find then-th ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,1, 2, 3, 4,... 阅读全文
posted @ 2015-11-09 06:13 树獭君 阅读(148) 评论(0) 推荐(0)
摘要:QuestionThere are a row ofnhouses, each house can be painted with one of thekcolors. The cost of painting each house with a certain color is different... 阅读全文
posted @ 2015-11-09 05:21 树獭君 阅读(173) 评论(0) 推荐(0)
摘要:QuestionThere are a row ofnhouses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a ... 阅读全文
posted @ 2015-11-09 03:57 树獭君 阅读(429) 评论(0) 推荐(0)
摘要:QuestionDesign an algorithm to encodea list of stringstoa string. The encoded string is then sent over the network and is decoded back to the original... 阅读全文
posted @ 2015-11-09 03:19 树獭君 阅读(479) 评论(0) 推荐(0)
摘要:Question Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, Hint: Sol 阅读全文
posted @ 2015-11-08 23:52 树獭君 阅读(243) 评论(0) 推荐(0)
摘要:QuestionSuppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is ... 阅读全文
posted @ 2015-11-08 06:00 树獭君 阅读(184) 评论(0) 推荐(0)
摘要:QuestionGiven a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in-order succe... 阅读全文
posted @ 2015-11-08 05:07 树獭君 阅读(257) 评论(0) 推荐(0)
摘要:First, we use recursive way.Successor 1 public class Solution { 2 public TreeNode inorderSuccessor(TreeNode root, TreeNode p) { 3 if (root... 阅读全文
posted @ 2015-11-08 05:07 树獭君 阅读(823) 评论(0) 推荐(0)
摘要:QuestionYou are given am x n2D grid initialized with these three possible values.-1- A wall or an obstacle.0- A gate.INF- Infinity means an empty room... 阅读全文
posted @ 2015-11-08 04:38 树獭君 阅读(254) 评论(0) 推荐(0)
摘要:QuestionAn image is represented by a binary matrix with0as a white pixel and1as a black pixel. The black pixels are connected, i.e., there is only one... 阅读全文
posted @ 2015-11-08 03:41 树獭君 阅读(256) 评论(0) 推荐(0)
摘要:QuestionAccording to theWikipedia's article: "TheGame of Life, also known simply asLife, is a cellular automaton devised by the British mathematician ... 阅读全文
posted @ 2015-11-08 00:59 树獭君 阅读(249) 评论(0) 推荐(0)
摘要:QuestionGiven an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist... 阅读全文
posted @ 2015-11-08 00:32 树獭君 阅读(179) 评论(0) 推荐(0)
摘要:QuestionGiven apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection between a lette... 阅读全文
posted @ 2015-11-07 23:31 树獭君 阅读(295) 评论(0) 推荐(0)
摘要:QuestionA group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 mar... 阅读全文
posted @ 2015-11-07 14:46 树獭君 阅读(459) 评论(0) 推荐(0)
摘要:QuestionYou are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 t... 阅读全文
posted @ 2015-11-07 12:23 树獭君 阅读(201) 评论(0) 推荐(0)
摘要:QuestionGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The ... 阅读全文
posted @ 2015-11-07 11:01 树獭君 阅读(173) 评论(0) 推荐(0)
摘要:QuestionRemove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string m... 阅读全文
posted @ 2015-11-07 05:48 树獭君 阅读(1233) 评论(0) 推荐(0)
摘要:Referrence: Oracle Java DocTwo levelstop level: public, or package-private (no explicit modifier)member level: public, private, protected, package-pri... 阅读全文
posted @ 2015-11-07 05:05 树獭君 阅读(172) 评论(0) 推荐(0)
摘要:面试时常问到这两种语言的区别,在此总结一下。Referrence: Udemy:python-vs-javaGenerally,Python ismuchsimpler to use, and more compact than Java. It is generally easier to lea... 阅读全文
posted @ 2015-11-07 04:03 树獭君 阅读(326) 评论(0) 推荐(0)
摘要:Referrence: BlogCompiled LanguagesExample: C, C++, JavaSource code needs to be compiled into bits and bytes that can be executed by computers.Java: so... 阅读全文
posted @ 2015-11-07 04:02 树獭君 阅读(362) 评论(0) 推荐(0)
摘要:面试的时候发现会问一些SQL的基本问题,在此总结一下。ProgramInterview/SQL这个网站上的问题还比较全。1. Join typeINNER JOIN: Returns all rows when there is at least one match in BOTH tablesLE... 阅读全文
posted @ 2015-11-07 02:12 树獭君 阅读(213) 评论(0) 推荐(0)
摘要:QuestionFollow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solut... 阅读全文
posted @ 2015-11-07 00:10 树獭君 阅读(159) 评论(0) 推荐(0)
摘要:QuestionDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Solutiondividend = divisor * quo... 阅读全文
posted @ 2015-11-06 05:26 树獭君 阅读(149) 评论(0) 推荐(0)
摘要:原文public class HashMapextends AbstractMapimplements Map, Cloneable, Serializable1.Hash table based implementation of theMapinterface. This implementat... 阅读全文
posted @ 2015-11-06 03:31 树獭君 阅读(305) 评论(0) 推荐(0)
摘要:原文What’s the difference between an interface and an abstract class in Java?It’s best to start answering this question with a brief definition of abstr... 阅读全文
posted @ 2015-11-06 03:22 树獭君 阅读(429) 评论(0) 推荐(0)
摘要:Reference: TutorialPoints, GeekforGeeksThecopy constructoris a constructor which creates an object by initializing it with an object of the same class... 阅读全文
posted @ 2015-11-06 03:06 树獭君 阅读(714) 评论(0) 推荐(0)
摘要:QuestionGiven an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the... 阅读全文
posted @ 2015-11-05 22:56 树獭君 阅读(224) 评论(0) 推荐(0)
摘要:QuestionGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthe... 阅读全文
posted @ 2015-11-05 21:59 树獭君 阅读(121) 评论(0) 推荐(0)
摘要:QuestionGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Yo... 阅读全文
posted @ 2015-11-05 11:31 树獭君 阅读(174) 评论(0) 推荐(0)
摘要:QuestionGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3w... 阅读全文
posted @ 2015-11-05 09:09 树獭君 阅读(179) 评论(0) 推荐(0)
摘要:Sum类的题目一般这样:input: nums[], targetoutput: satisfied arrays/ lists/ number拿到题目,首先分析:1. 是几个数的sum2. sum是要求等于target还是小于还是大于还是closest3. 返回的是原数组下标还是其他对于这类题目,... 阅读全文
posted @ 2015-11-05 02:26 树獭君 阅读(445) 评论(0) 推荐(0)
摘要:QuestionGiven an array ofnintegersnumsand atarget, find the number of index tripletsi, j, kwith0 = tmpTarget) {11 end--;12 ... 阅读全文
posted @ 2015-11-04 23:45 树獭君 阅读(188) 评论(0) 推荐(0)
摘要:QuestionGiven an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integer... 阅读全文
posted @ 2015-11-04 22:43 树獭君 阅读(154) 评论(0) 推荐(0)
摘要:Roman Numeral ChartV:5 X:10 L:50 C:100 D:500 M:1000规则:1. 重复次数表示该数的倍数2. 右加左减:较大的罗马数字右边记上较小的罗马数字,表示大数字加小数字较小的罗马数字右边记上较大的罗马数字,表示大数字减小数字左减的数字有限制,仅限于I... 阅读全文
posted @ 2015-11-04 12:49 树獭君 阅读(451) 评论(0) 推荐(0)
摘要:QuestionWrite a function to find the longest common prefix string amongst an array of strings.Solution第一思路是用Trie,但是对于一道Easy类别的题目,用Trie显然是杀鸡用牛刀。于是我们可以参... 阅读全文
posted @ 2015-11-04 10:02 树獭君 阅读(189) 评论(0) 推荐(0)
摘要:QuestionGiven a list of words and two wordsword1andword2, return the shortest distance between these two words in the list.For example,Assume that wor... 阅读全文
posted @ 2015-11-04 09:21 树獭君 阅读(188) 评论(0) 推荐(0)
摘要:QuestionGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the... 阅读全文
posted @ 2015-11-04 09:11 树獭君 阅读(175) 评论(0) 推荐(0)
摘要:QuestionGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wik... 阅读全文
posted @ 2015-11-04 02:07 树獭君 阅读(260) 评论(0) 推荐(0)
摘要:QuestionGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique lo... 阅读全文
posted @ 2015-11-04 00:50 树獭君 阅读(243) 评论(0) 推荐(0)
摘要:Question Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. F 阅读全文
posted @ 2015-11-03 11:21 树獭君 阅读(139) 评论(0) 推荐(0)
摘要:给定输入字符串,要求判断任意子字符串是否对称。基本思路就是DP写出DP表达式为 dp[i][j] = dp[i + 1][j - 1] && (s[i] == s[j]) dp[i][j]代表s(i,j)的子串是否对称注意在for循环赋值时,这里增长的对象其实是子串的长度。长度为奇数时:(->... 阅读全文
posted @ 2015-11-03 11:02 树獭君 阅读(285) 评论(0) 推荐(0)
摘要:QuestionGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?Solution这一题思路并不难。要满足follow-u... 阅读全文
posted @ 2015-11-03 07:49 树獭君 阅读(223) 评论(0) 推荐(0)
摘要:Question Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return a 阅读全文
posted @ 2015-11-02 03:28 树獭君 阅读(246) 评论(0) 推荐(0)