[leetcode]Given a string s, partition s such that every substring of the partition is a palindrome....
分类:
其他好文 时间:
2014-10-06 12:19:50
阅读次数:
200
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
点击打开原题链接
这个题剑指offer里也有,简单的递归即可,代码很清晰:...
分类:
其他好文 时间:
2014-10-05 22:56:09
阅读次数:
185
最长上升子序列LIS问题属于动态规划的初级问题,用纯动态规划的方法来求解的时间复杂度是O(n^2)。但是如果加上二叉搜索的方法,那么时间复杂度可以降到nlog(n)。 具体分析参考:http://blog.chinaunix.net/uid-26548237-id-3757779.html 代...
分类:
其他好文 时间:
2014-10-05 22:41:09
阅读次数:
194
Write a function to find the longest common prefix string amongst an array of strings.class Solution: # @return a string #最长公共前缀 def longestC...
分类:
编程语言 时间:
2014-10-05 20:35:58
阅读次数:
202
论文里面的神题,题意大概是找出当前字符串中的一个子串,使得这个子串由N个字符串循环构成,输出N最大的子串,如果有多输出字典序最小的一个。解决方法感觉很犀利。。首先,对于循环节长度为L的子串,必然有这个子串会经过str[0],str[L],str[2*L]...中的任意两个字符,也就是必然会经过str...
分类:
其他好文 时间:
2014-10-04 23:57:07
阅读次数:
319
例一:String.indexOf(String x):字符串x在字符串中第一次出现的下表索引,若不存在“x”,就返回-1String.substring(int beginindex):从字符串索引为beginindex開始截取,包含该索引String str = "陕西省|西安市|雁塔区";Sy...
分类:
其他好文 时间:
2014-10-04 14:46:26
阅读次数:
185
https://oj.leetcode.com/problems/minimum-window-substring/线性复杂度的限制下,考虑使用滑动窗口法。这个方法的思路就是维持一个窗口,窗口向右边界扩张以满足限制条件。窗口左边界收缩以尽量使其最小。注意这个题目可能是一个典型的滑动窗口方法的实现。外...
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2014-10-04 01:10:45
阅读次数:
200
9月27日后缀数组:【wikioi3160】最长公共子串dp:NOIP2001统计单词个数后缀自动机:【spoj1812】Longest Common Substring II【wikioi3160】最长公共子串【spoj7258】Lexicographical Substring Search扫描...
分类:
其他好文 时间:
2014-10-03 15:17:24
阅读次数:
1374
[leetcode]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 longest palindromic substring....
分类:
其他好文 时间:
2014-10-02 13:30:42
阅读次数:
217