2015年4月16日
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.将不同罗马字符和对应的数字做成字典,然后将依次转化。时间:55ms代码如下:class ... 阅读全文
posted @ 2015-04-16 22:45 NealCaffrey989 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2015-04-16 22:44 NealCaffrey989 阅读(96) 评论(0) 推荐(0) 编辑
  2015年4月11日
摘要: Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2015-04-11 20:07 NealCaffrey989 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.看到题目第一想法是将数字倒过来相减,看是否为0,但是会超时。原因是大部分可能并不是,所以循环中间就退出循环了。目前这个程序是按最左位与最右位逐次比较。时... 阅读全文
posted @ 2015-04-11 19:58 NealCaffrey989 阅读(87) 评论(0) 推荐(0) 编辑
  2015年4月10日
摘要: Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文
posted @ 2015-04-10 10:09 NealCaffrey989 阅读(105) 评论(0) 推荐(0) 编辑
  2015年4月9日
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321题目很简单,先判断数字的正负,再按位倒置数字就可以了。不过要考虑int的上限。时间:16ms代码如下:class Soluti... 阅读全文
posted @ 2015-04-09 21:42 NealCaffrey989 阅读(87) 评论(0) 推荐(0) 编辑
  2015年4月8日
摘要: The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
posted @ 2015-04-08 11:34 NealCaffrey989 阅读(104) 评论(0) 推荐(0) 编辑
  2015年4月7日
摘要: Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文
posted @ 2015-04-07 20:32 NealCaffrey989 阅读(113) 评论(0) 推荐(0) 编辑
  2015年4月6日
摘要: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文
posted @ 2015-04-06 19:23 NealCaffrey989 阅读(133) 评论(0) 推荐(0) 编辑
  2015年4月5日
摘要: 今天清明,再补一篇Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating l... 阅读全文
posted @ 2015-04-05 21:21 NealCaffrey989 阅读(130) 评论(0) 推荐(0) 编辑