思路参考这里#include#include#includeusing namespace std;#define Size 1000int table[Size+1][Size+1];int main(){ string A, B; while( cin>>A>>B )...
分类:
其他好文 时间:
2015-07-14 22:17:57
阅读次数:
121
Question: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 fa...
分类:
其他好文 时间:
2015-07-14 17:15:29
阅读次数:
106
题意:裸最长公共子序列
分析:
直接套用模型,注意初始化和实现的是细节
代码:
#include
#include
#include
#define max(a,b) a>b?a:b
using namespace std;
int dp[1010][1010];
string a,b;
int main()
{
while(cin>>a>>b){
for(int i=0;i<a.l...
分类:
其他好文 时间:
2015-07-14 15:37:56
阅读次数:
96
题目:
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Yo...
分类:
编程语言 时间:
2015-07-14 11:26:06
阅读次数:
140
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 longes...
分类:
其他好文 时间:
2015-07-14 09:48:50
阅读次数:
130
---恢复内容开始---方法1:brute force 时间复杂度 O(n^2) 空间复杂度 O(1)public class Solution { public int maxSubArray(int[] nums) { if (nums == null || nums.length ...
分类:
其他好文 时间:
2015-07-14 07:31:45
阅读次数:
94
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],...
分类:
其他好文 时间:
2015-07-13 22:22:20
阅读次数:
95
题目:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complet...
分类:
其他好文 时间:
2015-07-13 22:12:40
阅读次数:
102
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?2,1,?3,4,?1,2...
分类:
其他好文 时间:
2015-07-13 22:02:02
阅读次数:
142
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ...
分类:
其他好文 时间:
2015-07-13 20:13:08
阅读次数:
126