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 le...
分类:
其他好文 时间:
2015-08-19 13:14:00
阅读次数:
134
1 题目
Given a string,find the length of the longest substring without repeating characters. Forexample, the longest substring without repeating letters for"abcabcbb" is "abc", which the length is 3. F...
分类:
其他好文 时间:
2015-08-19 11:14:04
阅读次数:
167
题目地址:UVA 10100
题意:求两组字符串中最大的按顺序出现的相同单词数目。
思路:将字串中的连续的字母认作一个单词,依次计算出两个字符串中的单词,其中第1个字符串的单词序列为t1.word[1]…..t1.word[n],第2个字符串的单词序列为t2.word[1]…..t2.word[m]。然后将每个单词当成一个字符,使用LCS算法计算出两个字符串的最长公共子序列,该序列的长度就是最长...
分类:
其他好文 时间:
2015-08-18 21:30:39
阅读次数:
118
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-08-18 18:02:56
阅读次数:
198
1096. Consecutive Factors (20)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be fact...
分类:
其他好文 时间:
2015-08-18 14:01:37
阅读次数:
134
背景
最近开始研究算法,于是在leetcode上做算法题,第五题Longest Palindromic Substring便是关于回文子串的。
什么是回文字串
回文字符串是指将该字符串前后颠倒之后和该字符串一样的字符串。例如:a,aaaa,aba,abba…
最长回文子串
要求最长回文子串,就需要遍历每一个子串,时间复杂度是O(N²);判断字串是不是回文,时间复杂度是...
分类:
编程语言 时间:
2015-08-18 10:18:51
阅读次数:
172
最长公共子序列,英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。而最长公共子串(要求连续)和最长公共子序列是不同的。
#include "stdafx.h"
#include
#include
using names...
分类:
其他好文 时间:
2015-08-17 19:34:36
阅读次数:
116
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 le...
分类:
其他好文 时间:
2015-08-17 11:37:33
阅读次数:
123
题目
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is 3...
分类:
其他好文 时间:
2015-08-17 06:33:30
阅读次数:
232
Problem DescriptionThe signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutation, w...
分类:
其他好文 时间:
2015-08-17 06:29:05
阅读次数:
145