Use lMax get the maximum value of a sub SINGLE branch (left branch or right branch or just current node).Use gMax get the maximum value of the whole s...
分类:
其他好文 时间:
2015-03-18 08:56:01
阅读次数:
190
Need a helper function to return the binary tree maximum height. If the return value is -1, it means there is a imbalanced subbranch . 1 /** 2 * Defi....
分类:
其他好文 时间:
2015-03-18 07:47:44
阅读次数:
123
III is a kind of I. But it require 2 maximum value. So scan from begin and scan from end to record the maximum value for currrent index.Then scan the ...
分类:
其他好文 时间:
2015-03-18 07:46:13
阅读次数:
134
题意:给出n个数组成的序列,求乘积最大的连续子序列看的紫书,因为n最大为18,每个数最大为10,所以10^18用long long 能够存下, 直接枚举起点和终点找最大值就可以了 1 #include 2 #include 3 #include 4 #include 5 #includ...
分类:
其他好文 时间:
2015-03-18 01:02:50
阅读次数:
190
优先队列(priority queue)是一种用来维护由一组元素构成的集合S的数据结构,其中的每一个元素都有一个相关的值,称为关键字(key)。一个最大优先队列支持一下操作:
INSERT(S, x):把元素x插入集合S中。
MAXIMUM(S):返回S中具有最大关键字的集合。
EXTRACT-MAX(S):去掉并返回S中的具有最大关键字的元素。
INCREASE-KEY(...
分类:
编程语言 时间:
2015-03-17 21:52:58
阅读次数:
211
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet...
分类:
其他好文 时间:
2015-03-17 17:47:37
阅读次数:
140
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...
分类:
其他好文 时间:
2015-03-17 17:30:40
阅读次数:
159
1.header 里面的 meta标签name="viewport" 定义布局width=device-wdith 设置的宽度initial-scale=1.0 确保加载时候比例为1:1user-scalable=no 禁用缩放功能maximum-scale=1.0 确保禁用缩放功能后,用户能够滚动...
分类:
其他好文 时间:
2015-03-16 22:58:40
阅读次数:
200
题意:一个筛子有m个面,然后扔n次,求最大值的期望;思路:最大值为1 有1种,2有2n-1种, 3有3n -2n 种 所以为m的时有mn -(m-1)n 种,所以分别求每一种的概率,然后乘以这个值求和就可以。 1 #include 2 #include 3 #include 4 #inclu...
分类:
其他好文 时间:
2015-03-16 22:32:19
阅读次数:
102
Given a sequence of K integers { N1, N2, ..., NK}. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj} where 1 5 #include 6 #include 7 #...
分类:
其他好文 时间:
2015-03-16 19:10:05
阅读次数:
109