摘要: 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 which gives the sum of target.Note:Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d)The solution set must not contai 阅读全文
posted @ 2013-09-20 20:31 懒猫欣 阅读(208) 评论(0) 推荐(0)
摘要: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", &q 阅读全文
posted @ 2013-09-20 17:19 懒猫欣 阅读(247) 评论(0) 推荐(0)
摘要: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note:You are not suppose to use th 阅读全文
posted @ 2013-09-20 16:17 懒猫欣 阅读(132) 评论(0) 推荐(0)
摘要: Memset的原型是void *memset(void *s, char ch, size_t n);Memset是按字节赋值的,对char以外的类型赋0(00000000) -1(11111111)以外的值 阅读全文
posted @ 2013-09-20 15:46 懒猫欣 阅读(208) 评论(0) 推荐(0)
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a palindrome.Note:Have you consider that the string might be empty? This is a good questi 阅读全文
posted @ 2013-09-20 02:05 懒猫欣 阅读(194) 评论(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 consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.Your algorithm should run in O(n) complexity.unordered_set是C++自带的hash表class Solu 阅读全文
posted @ 2013-09-20 01:18 懒猫欣 阅读(241) 评论(0) 推荐(0)