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
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
[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
最近一直忙着写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
题目大意:
给出一棵树,每个点有商店,每个商店都有一个价格,Yaoge每次从x走到y都可以在一个倒卖商品,从中得取利益,当然,买一顶要在卖之前。但是没次走过一条路,这条路上的所有商品都会增加一个v。
输出每次的最大利益。
思路分析:
很容易想到树链剖分,可是关键在于如何维护这样一个变量,使得每次都要让买的再卖的前面。
维护变量 ltr 和 rtl ,表示从左去右和从右去左。
剖...
分类:
其他好文 时间:
2014-10-01 18:01:37
阅读次数:
268
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.
面DP题的考官都是神经病。。(吐...
分类:
其他好文 时间:
2014-10-01 13:15:31
阅读次数:
242
这题看起来和max subarray差不多,只是加法变乘法,尝试过用分治法,发现划分情况的时候特别麻烦。于是分析下这题本身的特点:1、对0较敏感,一旦有0,乘积就不变了,所以需要在遇到0 的时候将数组拆分2、如果没有0, 一旦相乘,绝对值肯定会变大,所以仅考虑正负号的问题就够了。若整个数组相乘是一个...
分类:
其他好文 时间:
2014-09-30 17:23:59
阅读次数:
206
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2014-09-30 17:19:19
阅读次数:
173
Maximum Entropy Model(最大熵模型) 推导
分类:
其他好文 时间:
2014-09-30 14:26:29
阅读次数:
156
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-09-29 03:53:16
阅读次数:
255