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-07-07 08:19:36
阅读次数:
151
Find a maximum sum of a compact subsequence of array elements and any double slice.
分类:
其他好文 时间:
2014-07-06 20:44:45
阅读次数:
351
Given a log of stock prices compute the maximum possible earning.
分类:
其他好文 时间:
2014-07-06 20:04:21
阅读次数:
259
Max Points on a LineGivennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.点和方向确定一条直线。需要两重循环,第一重循环遍历起始点a,第二重...
分类:
其他好文 时间:
2014-07-06 18:21:01
阅读次数:
175
Divide an array into the maximum number of same((-))sized blocks, each of which should contain an index P such that A[P - 1] A[P + 1].
分类:
其他好文 时间:
2014-07-06 15:30:31
阅读次数:
465
Find the maximum number of flags that can be set on mountain peaks.
分类:
其他好文 时间:
2014-07-06 15:07:09
阅读次数:
371
找书中权值和最大的路径,至少包含一个点。有点类似LCA(最近公共祖先),树的问题关键是如何划分子问题,然后递归求解。想到了可以返回两种结果,一个是单独路径的最大和,一种是子树的最大和,然后在求解的过程中不断的更新答案。 1 /** 2 * Definition for binary tree 3 ....
分类:
其他好文 时间:
2014-07-06 14:16:47
阅读次数:
187
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:
其他好文 时间:
2014-07-05 20:43:45
阅读次数:
246
Given a binary tree, find its maximum depth.
分类:
其他好文 时间:
2014-07-03 13:19:33
阅读次数:
251
【题目】
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
【题意】
给定一堆点,要求找出一条之前上的最大点数
【思路】
没什么好的方法,从每个点P出发,遍历所有的情况
从每个点P出发,斜率相同的点即为统一之前上的点
注意两种特殊情况:
1. 两个点重合(即为同一个点)
...
分类:
其他好文 时间:
2014-07-02 06:52:06
阅读次数:
171