Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ...
分类:
其他好文 时间:
2014-11-07 00:58:54
阅读次数:
259
#include #include using namespace std;char line[1001];char line2[2003];int syslen(char str[], int start) { int len = 1; int p = start - 1; in...
分类:
其他好文 时间:
2014-11-07 00:52:32
阅读次数:
145
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ...
分类:
编程语言 时间:
2014-11-07 00:49:35
阅读次数:
210
Problem Description
In computer science, the longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence's elements are in sorted order, lowest to hig...
分类:
其他好文 时间:
2014-11-06 21:57:19
阅读次数:
187
解题思路:
1.简单动态规划。
2.纠结的边界处理,不建议采用dp[i]表示s前i个字符能否取得这种方法。用这种方法实现字符串储存的时候会比较麻烦。而且如果存储不对边界处理会非常麻烦……(最先我采用的是这种方法,结果WA 4次,多次处理还是有长度为0和长度为1的情况无法分辨,最终放弃)...
分类:
其他好文 时间:
2014-11-06 13:09:20
阅读次数:
176
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...
分类:
其他好文 时间:
2014-11-06 12:57:50
阅读次数:
176
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int dp[1010][1010];
int main()
{
int i,j,n,m;
string a,b;
while(getline(cin,a))
{
g...
分类:
其他好文 时间:
2014-11-05 19:43:25
阅读次数:
191
POJ 2533 Longest Ordered Subsequence(LIS:最长上升子序列)
http://poj.org/problem?id=2533
题意:
给你一个长度为n的数字序列, 要你求该序列中的最长(严格)上升子序列的长度.
分析:
解法一: O(n^2)复杂度.
令dp[i]==x 表示以第i个数字结尾的上升子序列中最长的为x长度.
初始化: dp[0]=0且dp[i]=1 i>=1时.
状态转移: dp[i] =...
分类:
其他好文 时间:
2014-11-05 13:04:35
阅读次数:
188
poj_2533_Longest Ordered Subsequence poj_1260_Pearls hdu_1025_Constructing Roads In JGShining's King hdu_1074_Doing Homework...
分类:
其他好文 时间:
2014-11-04 17:39:20
阅读次数:
144
Surprising Strings
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 6017
Accepted: 3934
Description
The D-pairs of a string of letters are the ordered pai...
分类:
其他好文 时间:
2014-11-04 17:31:40
阅读次数:
192