3. Longest Substring Without Repeating Characters
摘要:计算一个字符串的最长不重复字符串长度 例如abcdcfdgq 截取的是cfdgq 长度为5 1 public int lengthOfLongestSubstring(String s) { 2 if(s == null || s.length() == 0){ 3 return 0; 4 } 5
阅读全文
posted @
2016-01-29 17:55
酒仙桥吴彦祖
阅读(180)
推荐(0) 编辑
1. Two Sum
摘要:Input: numbers={2, 7, 11, 15}, target=9Output: index1=1, index2=2 给出目标target,找到数组中相加等于target的两元素的下标 此题在我们脑中最先想到的思路是两重循环,找到所有组合,时间复杂度为O(n2),但是然并卵,这显然不是
阅读全文
posted @
2016-01-28 15:05
酒仙桥吴彦祖
阅读(128)
推荐(0) 编辑
10. Regular Expression Matching
摘要:此题为正则表达式匹配,只实现两个字符的匹配,'*'和'.' '.' Matches any single character. '*' Matches zero or more of the preceding element. Some examples: isMatch("aa","a") →
阅读全文
posted @
2016-01-27 15:16
酒仙桥吴彦祖
阅读(120)
推荐(0) 编辑
9. Palindrome Number
摘要:思路1:利用Reverse Integer的方法,求的转换后的数字,然后比较是否相等。思路2:从两头依次取数字比较,向中间推进。 1 // Revert Integer解法,把反转后的和原数据对比,相同返回true 2 public static boolean isPalindro...
阅读全文
posted @
2016-01-25 16:03
酒仙桥吴彦祖
阅读(125)
推荐(0) 编辑
8. String to Integer (atoi)
摘要:此题不难,主要在于你能否考虑到多种细节情况,下面总结如下1.有空格 " 134 45"2.有符号 " + 23 4" "- 234"3.有其他字符 "af+234"4.超出临界值 "9223372036854775809"代码如下: 1 public static int atoi...
阅读全文
posted @
2016-01-25 11:27
酒仙桥吴彦祖
阅读(131)
推荐(0) 编辑
7. Reverse Integer
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321此题简单,但是需要考虑一些边界上的处理会在面试中加分。另外这里考虑了一下溢出处理 1 public static in...
阅读全文
posted @
2016-01-19 21:22
酒仙桥吴彦祖
阅读(132)
推荐(0) 编辑
6.ZigZag Conversion
摘要:题目要求: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 fo...
阅读全文
posted @
2016-01-19 20:41
酒仙桥吴彦祖
阅读(143)
推荐(0) 编辑
重刷Leetcode!
摘要:忧患意识,提升自己,不能在一家公司吊死,随时做好迎接高薪的准备。彦祖说做人不吃咸鱼,那和咸鱼有什么区别!今天开始刷Leetcode,每道题的思路会记录在博客里。天地为鉴!
阅读全文
posted @
2016-01-19 19:32
酒仙桥吴彦祖
阅读(144)
推荐(0) 编辑