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 complete as many transactions as you like (ie, buy one and...
分类:
其他好文 时间:
2015-06-30 10:32:15
阅读次数:
120
http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/This question is pretty similar to the solution of Maximum Depth of Binary Tree, the only...
分类:
其他好文 时间:
2015-06-30 06:34:15
阅读次数:
138
题目连接: http://poj.org/problem?id=3061题目大意: 一个有n个数的序列和一个整数s,找出一个最短序列,最短序列中各个数相加的和大于等于s。解题思路: 题目比较简单,写博记录一下思想——尺取法,用其他方法也可以解决。 1 //#include 2 #includ...
分类:
其他好文 时间:
2015-06-29 21:57:01
阅读次数:
118
B. Maximum Submatrix 2Time Limit: 20 SecMemory Limit: 256 MB题目连接http://codeforces.com/problemset/problem/375/BDescriptionYou are given a matrix consis...
分类:
编程语言 时间:
2015-06-29 13:11:53
阅读次数:
223
题目:
Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length ...
分类:
其他好文 时间:
2015-06-29 10:06:13
阅读次数:
103
1 class Solution { 2 public: 3 /** 4 * @param A, B: Two strings. 5 * @return: The length of longest common subsequence of A and B. 6 ...
分类:
其他好文 时间:
2015-06-28 17:04:49
阅读次数:
107
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 le...
分类:
其他好文 时间:
2015-06-27 06:24:03
阅读次数:
127
Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that posi...
分类:
其他好文 时间:
2015-06-25 21:15:22
阅读次数:
137
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Hide TagsHash TableMath给出平面上的点,问一条直线最多穿过几个点.要不是之前看过这个...
分类:
其他好文 时间:
2015-06-25 19:18:34
阅读次数:
124
最大乘积子序列思想:动态规划+最大最小数组 状态方程:考虑到负数,所以加上一个min。 max[i] = Max(max[i-1]*nums[i],min[i-1]*nums[i],nums[i]); min[i] = Min(max[i-1]*nums[i],min[i-1]*n...
分类:
其他好文 时间:
2015-06-25 12:03:29
阅读次数:
95