2014年5月22日
摘要: 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: Elements in a triplet (a,b,c) must be... 阅读全文
posted @ 2014-05-22 21:18 JessiaDing 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings. 要减少比较次数。在实现过程中我的想法是,2个2个比较,那么只要遍历一次数组就好。而且,在比较过程中,以较短的那个长度作为最大比较距离,较长的后半部分是不可能存在公共前缀的。 public class Soluti... 阅读全文
posted @ 2014-05-22 16:13 JessiaDing 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 其实这两道题只是把输入输出反过来而已。不过在写代码之前,还是了解了Roman数字的表示方法。 基本字符 I ... 阅读全文
posted @ 2014-05-22 15:05 JessiaDing 阅读(103) 评论(0) 推荐(0) 编辑