题目 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lon ...
分类:
其他好文 时间:
2016-04-11 18:11:35
阅读次数:
155
题目:
Write a function to find the longest common prefix string amongst an array of strings.
题目大意:
写一个函数,求一个字符串数组中最长的公共前缀子串。
思路:
在做这道题之前先要了解一下什么叫做公共前缀子串。在英语中一个单词可以分为前缀、词根、后缀三部分,所谓前缀就是指在单词的开...
分类:
其他好文 时间:
2016-04-11 12:32:43
阅读次数:
128
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo ...
分类:
其他好文 时间:
2016-04-11 07:10:54
阅读次数:
133
计算最长的无重复字符的串长 用HashMap记住重复的单词及其位置。当重复时,让tempStart指针移到重复位置+1,如果start指针小于tempStart,则更新start指针,长度就是当前重复的位置 - start。读到字符串末尾时还需要判断一次 ...
分类:
其他好文 时间:
2016-04-10 12:54:35
阅读次数:
112
因为要算匹配长度,所以要记录起始的位置。思路上要分三种情况吧,一种是完全匹配,一种是未匹配的是‘)’,一种是未匹配的是‘(’。如果发现没有左括号可以和右括号匹配,那么只要把右括号位置设置为start,重新开始新一轮的寻找就可以了;如果没有右括号可以和左括号匹配,则要用当前位置减去堆栈栈顶的左括号位置 ...
分类:
其他好文 时间:
2016-04-10 12:42:46
阅读次数:
216
这题不能使用递归来写,因为有一个输入长度是17173,会爆栈。因此得手动模拟栈调用。 ...
分类:
其他好文 时间:
2016-04-10 01:01:45
阅读次数:
110
104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from th ...
分类:
其他好文 时间:
2016-04-09 12:19:07
阅读次数:
160
3. Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. For example, ...
分类:
其他好文 时间:
2016-04-09 12:15:03
阅读次数:
110