摘要: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文
posted @ 2013-11-10 19:07 七年之后 阅读(381) 评论(0) 推荐(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 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-11-09 20:53 七年之后 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 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 integers.... 阅读全文
posted @ 2013-11-09 19:07 七年之后 阅读(184) 评论(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 @ 2013-11-09 18:02 七年之后 阅读(208) 评论(0) 推荐(0) 编辑
摘要: const string roman[]={ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", & 阅读全文
posted @ 2013-11-08 18:11 七年之后 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思考:罗马数字有I,V,X,L,C,D,M。其中4,9左减,其他右加。class Solution {public: string intToRoman(int num) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance... 阅读全文
posted @ 2013-11-08 11:45 七年之后 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo... 阅读全文
posted @ 2013-11-08 00:52 七年之后 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the restriction of using extra space.You could also try reversing an integer. Howe 阅读全文
posted @ 2013-11-07 16:24 七年之后 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are r 阅读全文
posted @ 2013-11-07 15:54 七年之后 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!If the integer's last digit is 0, what sho 阅读全文
posted @ 2013-11-07 11:29 七年之后 阅读(161) 评论(0) 推荐(0) 编辑