码迷,mamicode.com
首页 >  
搜索关键字:maximum product suba    ( 9145个结果
hdu 5052 Yaoge’s maximum profit
Yaoge’s maximum profitTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 442Accepted Submission(s): ...
分类:其他好文   时间:2014-10-04 13:04:46    阅读次数:246
Leetcode:maximum_depth_of_binary_tree题解
给定一个二叉树,求它的最大深度。最大深度是沿从根节点,到叶节点最长的路径。...
分类:其他好文   时间:2014-10-04 01:10:05    阅读次数:186
Ural 1146 Maximum Sum(DP)
题目地址:Ural 1146 这题是求最大子矩阵和。方法是将二维转化一维。 首先用n*n的方法来确定矩阵的列。需要先进行预处理,只对每行来说,转化成一维的前缀和,这样对列的确定只需要前后两个指针来确定,只需要用前缀和相减即可得到。前后两个指针用n*n的枚举。 确定好了哪几列,那么再确定行的时候就转化成了一维的最大连续子序列的和。再来一次O(n)的枚举就可以。 这样,总复杂就变成了O(n^3...
分类:其他好文   时间:2014-10-03 22:40:35    阅读次数:205
Best Time to Buy and Sell Stock III
题目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...
分类:其他好文   时间:2014-10-03 13:37:34    阅读次数:225
HDU 3455 Leap Frog(线性DP)
Problem Description Jack and Jill play a game called "Leap Frog" in which they alternate turns jumping over each other. Both Jack and Jill can jump a maximum horizontal distance of 10 units in any ...
分类:其他好文   时间:2014-10-03 00:03:23    阅读次数:361
LeerCode 123 Best Time to Buy and Sell Stock III之O(n)解法
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-02 13:58:53    阅读次数:321
抽象工厂模式
一、抽象工厂(Abstract Factory)模式抽象工厂模式是全部形态的工厂模式中最为抽象和最具一般性的一种形态。为了方便引进抽象工厂模式,引进一个新概念:产品族(Product Family)。所谓产品族,是指位于不同产品等级结构,功能相关联的产品组成的家族。如图:图中一共同拥有四个产品族,分...
分类:其他好文   时间:2014-10-02 13:31:23    阅读次数:252
Longest Palindromic Substring
[leetcode]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 palindromic substring....
分类:其他好文   时间:2014-10-02 13:30:42    阅读次数:217
DP Leetcode - Maximum Product Subarray
最近一直忙着写paper,很久没做题,一下子把题目搞复杂了。。思路理清楚了非常简单,每次只需更新2个值:最大乘积和最小乘积。最大乘积被更新有三种可能:当前A[i]>0,乘以前面最大的数(>0),得到新的最大乘积;当前A[i]0,(A[i-1]==0。最小乘积同理。。 class Solution { public: int Max(int a, int b, int c) {...
分类:其他好文   时间:2014-10-02 02:54:12    阅读次数:170
Hdu 5052 Yaoge’s maximum profit(树链剖分)
题目大意: 给出一棵树,每个点有商店,每个商店都有一个价格,Yaoge每次从x走到y都可以在一个倒卖商品,从中得取利益,当然,买一顶要在卖之前。但是没次走过一条路,这条路上的所有商品都会增加一个v。 输出每次的最大利益。 思路分析: 很容易想到树链剖分,可是关键在于如何维护这样一个变量,使得每次都要让买的再卖的前面。 维护变量 ltr 和 rtl ,表示从左去右和从右去左。 剖...
分类:其他好文   时间:2014-10-01 18:01:37    阅读次数:268
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!