12 2016 档案

摘要: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: The solution set m... 阅读全文
posted @ 2016-12-09 23:22 copperface 阅读(212) 评论(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"... 阅读全文
posted @ 2016-12-07 22:22 copperface 阅读(252) 评论(0) 推荐(0)
摘要:Write a function to find the longest common prefix string amongst an array of strings.1234567891011121314class Solution {public: string longestCommonPrefix(vector& strs) { if(strs.empty()) r... 阅读全文
posted @ 2016-12-07 16:22 copperface 阅读(146) 评论(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. You may assume that each input would have exactly... 阅读全文
posted @ 2016-12-07 16:21 copperface 阅读(217) 评论(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 zero.Note: The solution set must not contain dupli... 阅读全文
posted @ 2016-12-07 16:21 copperface 阅读(234) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.分析从前往后扫描,因为左减数字只能最多一位,并且比当前数字小,所以扫描的时候不断判断当前罗马字符和上一个的大小,如果s[i-1] 0 && map(s[i]) > map(s[i - 1... 阅读全文
posted @ 2016-12-04 15:30 copperface 阅读(207) 评论(0) 推荐(0)
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.分析罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制... 阅读全文
posted @ 2016-12-04 14:45 copperface 阅读(219) 评论(0) 推荐(0)