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,1...
分类:
其他好文 时间:
2015-04-18 20:23:36
阅读次数:
130
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],
the contiguous subarray [2,3] has the largest produ...
分类:
其他好文 时间:
2015-04-17 22:23:08
阅读次数:
170
题目如下:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.再简单不过的一题了,懒得写解释直接上代码了。/** * Definition for a poi...
分类:
其他好文 时间:
2015-04-17 21:45:48
阅读次数:
110
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-04-17 15:17:10
阅读次数:
148
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 exists one unique longest palindrom...
分类:
其他好文 时间:
2015-04-17 13:55:59
阅读次数:
162
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1,
..., Nj } where 1 Maximum Subsequence is the continuous subsequence which has the largest su...
分类:
其他好文 时间:
2015-04-17 11:37:02
阅读次数:
105
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 complete a...
分类:
其他好文 时间:
2015-04-16 23:39:29
阅读次数:
145
题目链接:Maximum Depth of Binary Tree
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 leaf node.
这道题...
分类:
其他好文 时间:
2015-04-16 10:25:57
阅读次数:
123
题目大意: 对整数串S,求其两个不相交的子串s1、s2,使得s1+s2的值最大。方法:DP, lt[i]代表以第i个元素结尾的串最大值
rt[i]代表以第i个元素开头的串的最大值
那么设置一个rtm[i]代表取后i个元素之中最大连续子串的和很显然,lt[i]=max(a[i],lt[i-1]+a[i]);
rt[i]=max(a[i],rt[i+1]+a[i]);
rtm[i]=ma...
分类:
其他好文 时间:
2015-04-15 21:31:49
阅读次数:
142
题目:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest...
分类:
其他好文 时间:
2015-04-15 21:20:54
阅读次数:
101