2013年5月25日

摘要: Problem:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"Analysis:Also a backtracking problem. Each time eit 阅读全文
posted @ 2013-05-25 14:33 freeneng 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Problem: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-05-25 13:08 freeneng 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Problem: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 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 contain duplicate quadru 阅读全文
posted @ 2013-05-25 10:42 freeneng 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Problem: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 may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. The sum that is clo... 阅读全文
posted @ 2013-05-25 10:27 freeneng 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Problem:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c) must be in non-descending order. (ie,a?b?c)The solution set must not contain duplicate triplets. For example, given... 阅读全文
posted @ 2013-05-25 10:03 freeneng 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Problem:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Analysis:In roman number system, there are 3 special cases1. 900 or 4002. 90 or 403. 9 or 4Process the integer number digit by digit, if it's 9 or 4, process it separately. Then if i 阅读全文
posted @ 2013-05-25 09:40 freeneng 阅读(118) 评论(0) 推荐(0) 编辑

导航

点击右上角即可分享
微信分享提示