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 lea...
分类:
其他好文 时间:
2014-10-21 22:58:39
阅读次数:
235
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...
分类:
其他好文 时间:
2014-10-21 22:52:27
阅读次数:
278
采用的的是小牛的写法,蒟蒻第一次写。。
RMQ (Range Minimum/Maximum Query)问题是指:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j
这里介绍ST算法:采用动态规划的思想:详见
士兵杀敌(三)
时间限制:2000 ms | 内存限制:65535 KB
难度:5
描述
南将军统率着N个士兵,士兵分...
分类:
编程语言 时间:
2014-10-21 01:05:37
阅读次数:
227
题目描述: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...
分类:
其他好文 时间:
2014-10-20 08:38:54
阅读次数:
125
Max Points on a LineGivennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.c++版本:/** * Definition for a poi....
分类:
其他好文 时间:
2014-10-19 22:42:21
阅读次数:
225
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...
分类:
其他好文 时间:
2014-10-19 22:35:19
阅读次数:
165
题目:给两个字符串S和T,判断T在S中出现的次数。
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence...
分类:
其他好文 时间:
2014-10-19 17:09:51
阅读次数:
190
Leetcode 加新题了Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array ...
分类:
其他好文 时间:
2014-10-19 15:36:04
阅读次数:
251
Language:
Default
Longest Ordered Subsequence
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 33986
Accepted: 14892
Description
A numeric sequence of a...
分类:
其他好文 时间:
2014-10-19 11:38:30
阅读次数:
249
题意:给你一个数列,求出数列中不相交的两个子段和,要求和最大。
Sol:对于每个i来说,求出 [ 0 ~ i-1 ] 的最大子段和以及 [ i ~ n-1 ] 的最大子段和,在加起来,求一个最大的就可以了。
[ 0 ~ i-1 ] 的最大子段和从左向右扫描 , [ i ~ n-1 ] 从右向左扫描。
复杂度O(n)
#include
#include
using namespace ...
分类:
其他好文 时间:
2014-10-18 21:03:16
阅读次数:
171