Write a function to find the longest common prefix string amongst an array of strings. class Solution { public: string longestCommonPrefix(vector& str...
分类:
其他好文 时间:
2015-10-30 09:20:08
阅读次数:
165
问题链接:https://leetcode.com/problems/longest-palindromic-substring/ Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there ...
分类:
其他好文 时间:
2015-10-30 02:21:57
阅读次数:
199
问题链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, find the length of the longest substring without repeating characters. For example, the longe...
分类:
其他好文 时间:
2015-10-29 06:21:35
阅读次数:
182
A simple application to binary tree traversal.class Solution { typedef pair Rec; // last val - length unsigned ret; void go(TreeNode *p, Rec ...
分类:
其他好文 时间:
2015-10-28 12:09:31
阅读次数:
140
今天闲来无事又刷了几道。Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parent...
分类:
其他好文 时间:
2015-10-27 22:05:04
阅读次数:
173
最长公共子序列(LCS,Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。而最长公共子串(要求连续)和最长公共子序列是不同的。设X(m)={x(1), x(2)...
分类:
其他好文 时间:
2015-10-26 00:37:29
阅读次数:
202
package cn.edu.xidian.sselab;/*** Given a binary tree, find its maximum depth.* The maximum depth is the number of nodes along the longest path from t...
分类:
其他好文 时间:
2015-10-24 23:32:01
阅读次数:
262
将所有合法的括号即一对()都消除,用桟保存其中不合法的括号即单个(或)在字符串中的下标。那么每两个不合法之间的下标之差减1就是中间的合法串长度,依次从后向前比较,选出最大的字符串。 1 class Solution { 2 public: 3 int longestValidParenthe...
分类:
其他好文 时间:
2015-10-23 10:16:43
阅读次数:
135
Write a function to find the longest common prefix string amongst an array of strings.解法:从所有的string的头到尾的字母逐一比较即可。class Solution {public: string lon...
分类:
其他好文 时间:
2015-10-22 12:28:49
阅读次数:
187
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...
分类:
其他好文 时间:
2015-10-22 12:04:38
阅读次数:
148