摘要: 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 whic... 阅读全文
posted @ 2015-05-02 11:58 TonyLuis 阅读(188) 评论(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 telephon... 阅读全文
posted @ 2015-05-02 10:20 TonyLuis 阅读(232) 评论(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 @ 2015-04-29 20:14 TonyLuis 阅读(269) 评论(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-04-29 11:02 TonyLuis 阅读(172) 评论(0) 推荐(0)
摘要: Write a function to find the longest common prefix string amongst an array of strings.解题思路:老实遍历即可,注意边界条件:JAVA实现: static public String longestCommonPre... 阅读全文
posted @ 2015-04-29 10:44 TonyLuis 阅读(179) 评论(0) 推荐(0)
摘要: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.解题思路:类似上题,方法多多,本题直接给出上题中字典匹配的代码:JAVA实现:stati... 阅读全文
posted @ 2015-04-29 09:35 TonyLuis 阅读(165) 评论(0) 推荐(0)
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.本题思路比较简单,难度主要集中在罗马数字本身,直接贴代码。思路一,从高位开始:JAVA:... 阅读全文
posted @ 2015-04-29 09:23 TonyLuis 阅读(168) 评论(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 @ 2015-04-28 21:53 TonyLuis 阅读(221) 评论(0) 推荐(0)
摘要: Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.... 阅读全文
posted @ 2015-04-28 21:16 TonyLuis 阅读(315) 评论(0) 推荐(0)
摘要: Determine whether an integer is a palindrome. Do this without extra space.解题思路一:双指针法,逐位判断Java代码如下: static public boolean isPalindrome(int x) { if (x ... 阅读全文
posted @ 2015-04-26 10:13 TonyLuis 阅读(197) 评论(0) 推荐(0)