LeetCode #14 Longest Common Prefix (E)

摘要: [Problem]Write a function to find the longest common prefix string amongst an array of strings.[Analysis]思路非常简单,循环验证每一个字符串就可以通过OJ,代码也没有优化。[Solution]pu... 阅读全文
posted @ 2015-10-09 22:33 张惬意 阅读(125) 评论(0) 推荐(0) 编辑

LeetCode #13 Roman to Integer (E)

摘要: [Problem]Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.[Analysis]建立一个字符到数字的map之后只需要抓住两个条件:... 阅读全文
posted @ 2015-10-09 22:28 张惬意 阅读(107) 评论(0) 推荐(0) 编辑

LeetCode #12 Integer to Roman (M)

摘要: [Problem]Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.[Analysis]由于题目提示输入的范围是1至3999,这题我采用了... 阅读全文
posted @ 2015-10-09 22:18 张惬意 阅读(95) 评论(0) 推荐(0) 编辑

LeetCode #11 Container With Most Water (M)

摘要: [Problem]Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endp... 阅读全文
posted @ 2015-10-09 22:12 张惬意 阅读(105) 评论(0) 推荐(0) 编辑

LeetCode #10 Regular Expression Matching (H)

摘要: [Problem]Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding el... 阅读全文
posted @ 2015-10-06 02:20 张惬意 阅读(104) 评论(0) 推荐(0) 编辑

LeetCode #9 Palindrome Number (E)

摘要: [Problem]Determine whether an integer is a palindrome. Do this without extra space.[Analysis]这题不能转换为String来做因为要求constant space。只要依次比较头尾两个数字就可以了。[Solut... 阅读全文
posted @ 2015-10-06 01:50 张惬意 阅读(91) 评论(0) 推荐(0) 编辑

Leetcode #8 String to Integer (atoi) (E)

摘要: [Problem]Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see b... 阅读全文
posted @ 2015-10-06 01:43 张惬意 阅读(93) 评论(0) 推荐(0) 编辑

LeetCode #7 Reverse Integer (E)

摘要: [Problem]Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321[Analysis]这题不难,关键是要注意overflow的处理,因为reverse后的数字有可能超出Int... 阅读全文
posted @ 2015-10-02 00:06 张惬意 阅读(127) 评论(0) 推荐(0) 编辑

LeetCode #6 ZigZag Conversion (E)

摘要: [Problem]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 fixe... 阅读全文
posted @ 2015-10-01 23:51 张惬意 阅读(127) 评论(0) 推荐(0) 编辑

LeetCode #5 Longest Palindromic Substring (M)

摘要: [Problem]Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique l... 阅读全文
posted @ 2015-10-01 23:03 张惬意 阅读(147) 评论(0) 推荐(0) 编辑