解题报告
求最长路。
用SPFA求最长路,初始化图为零,dis数组也为零
#include
#include
#include
#include
#include
#define inf 99999999
#define N 110
using namespace std;
int mmap[N][N],dis[N],vis[N],n;
void spfa(int s)
{
...
分类:
其他好文 时间:
2014-07-24 17:43:16
阅读次数:
280
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2014-07-24 12:11:55
阅读次数:
253
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 lo...
分类:
其他好文 时间:
2014-07-24 00:49:07
阅读次数:
200
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2014-07-23 16:19:41
阅读次数:
234
题目一:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, ...
分类:
其他好文 时间:
2014-07-22 23:04:12
阅读次数:
246
Write a function to find the longest common prefix string amongst an array of strings.题解:以strs[0]为模板,每次挨个查看是否所有的串里面是否第i位上都和strs[0]一样,如果都一样,把i位置上的字符放到a...
分类:
其他好文 时间:
2014-07-21 23:31:00
阅读次数:
267
Sum of Consecutive Prime Numbers
Description
Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive ...
分类:
其他好文 时间:
2014-07-21 22:18:12
阅读次数:
222
题目链接 Write a function to find the longest common prefix string amongst an array of strings. 题目的意思说的不是很清楚,开始理解成了求任意两个字符串的前缀中的最长者。但是本题的意思是求所有字符串的最长公共前缀,...
分类:
其他好文 时间:
2014-07-21 09:14:25
阅读次数:
225
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-07-21 09:07:24
阅读次数:
207
最长上升子序列问题 代码(C)本文地址: http://blog.csdn.net/caroline_wendy题目: 有一个长为n的数列a. 请求出这个序列中最长上升子序列的长度. 最长上升子序列的数字之间可以有间隔.即最长上升子序列(LIS, Longest Increasing Subsequence), 例如: n=5, a={4,2,3,1,5}, result=3(2,3,5).使用动...
分类:
其他好文 时间:
2014-07-20 22:34:43
阅读次数:
297