摘要: 题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integ... 阅读全文
posted @ 2014-07-22 11:35 爱做饭的小莹子 阅读(3890) 评论(1) 推荐(0) 编辑
摘要: 题目:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array w... 阅读全文
posted @ 2014-07-22 11:05 爱做饭的小莹子 阅读(3399) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum... 阅读全文
posted @ 2014-07-22 05:13 爱做饭的小莹子 阅读(6698) 评论(3) 推荐(1) 编辑
摘要: Hashtable:1. key和value都不许有null值2. 使用enumeration遍历3. 同步的,每次只有一个线程能够访问4. 在java中Hashtable是H大写,t小写,而HashMap是H大写,M大写HashMap:1. key和value可以有null值2. 使用itera... 阅读全文
posted @ 2014-07-22 04:10 爱做饭的小莹子 阅读(2199) 评论(0) 推荐(1) 编辑
摘要: 题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the tw... 阅读全文
posted @ 2014-07-22 03:44 爱做饭的小莹子 阅读(6868) 评论(3) 推荐(2) 编辑
摘要: 题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a funct... 阅读全文
posted @ 2014-07-22 00:40 爱做饭的小莹子 阅读(3299) 评论(0) 推荐(0) 编辑
摘要: 题目: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).You are given a target ... 阅读全文
posted @ 2014-07-21 11:55 爱做饭的小莹子 阅读(3406) 评论(1) 推荐(0) 编辑
摘要: 题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorte... 阅读全文
posted @ 2014-07-21 10:44 爱做饭的小莹子 阅读(4269) 评论(1) 推荐(0) 编辑
摘要: Reference: http://blog.csdn.net/lbyxiafei/article/details/9375735题目:Implement int sqrt(int x).Compute and return the square root of x.题解: 这道题很巧妙的运用了二... 阅读全文
posted @ 2014-07-21 09:34 爱做饭的小莹子 阅读(4241) 评论(2) 推荐(1) 编辑
摘要: 题目:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the... 阅读全文
posted @ 2014-07-21 08:31 爱做饭的小莹子 阅读(4074) 评论(0) 推荐(0) 编辑