摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2015-05-11 17:39 amazingzoe 阅读(177) 评论(0) 推荐(0)
摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2015-05-11 16:52 amazingzoe 阅读(157) 评论(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 of 阅读全文
posted @ 2015-05-11 13:37 amazingzoe 阅读(157) 评论(0) 推荐(0)
摘要: 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 two nu... 阅读全文
posted @ 2015-05-11 11:03 amazingzoe 阅读(108) 评论(0) 推荐(0)
摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2015-05-11 10:31 amazingzoe 阅读(122) 评论(0) 推荐(0)
摘要: There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should... 阅读全文
posted @ 2015-05-10 19:22 amazingzoe 阅读(152) 评论(0) 推荐(0)
摘要: Given a range [m, n] where 0 m位数,一定会出现100…0的情况,AND的结果为100…00如果n位数=m位数,从最高位开始分析,如果n和m该位上的数字相等,考虑下一位,直到某位上n=1,m=0(因为n>m)。到这种情况时,一定又会出现100…0的情况,所以后面的这些数字... 阅读全文
posted @ 2015-05-09 16:59 amazingzoe 阅读(117) 评论(0) 推荐(0)
摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-05-09 13:41 amazingzoe 阅读(231) 评论(0) 推荐(0)
摘要: Description:Count the number of prime numbers less than a non-negative number,nclick to show more hints.References:How Many Primes Are There?Sieve of ... 阅读全文
posted @ 2015-05-09 12:21 amazingzoe 阅读(136) 评论(0) 推荐(0)
摘要: Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?分... 阅读全文
posted @ 2015-05-08 23:50 amazingzoe 阅读(165) 评论(0) 推荐(0)