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 contiguous subarray [2,3] has the largest...
分类:
其他好文 时间:
2015-01-15 22:12:45
阅读次数:
169
题目:
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 contiguous subarray [2,3] has the l...
分类:
编程语言 时间:
2015-01-15 13:02:10
阅读次数:
229
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),...
分类:
其他好文 时间:
2015-01-15 09:30:17
阅读次数:
172
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 on...
分类:
其他好文 时间:
2015-01-15 09:27:56
阅读次数:
187
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
[3,4],
[...
分类:
其他好文 时间:
2015-01-14 22:53:47
阅读次数:
153
一、问题描述0-1背包问题,部分背包问题。分别实现0-1背包的DP算法,部分背包的贪心算法和DP算法。二、算法原理(1)0-1背包的DP算法 0-1背包问题:有n件物品和一个容量为W的背包。第i件物品的重量是w[i],价值是v[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价....
分类:
编程语言 时间:
2015-01-14 00:42:06
阅读次数:
225
题目意思:
http://acm.hdu.edu.cn/showproblem.php?pid=2059
题目没有说明白的是,不能用电动车剩余的能力,每次都要充满。
题目分析:
动态规划问题,可以对站点进行DP,加上起点和终点一共有n+2个站,起点表示站点0,dp[n+1]就是乌龟的最优时间,即最短时间,那么动态转化方程为:dp[i]=min(dp[i],dp[j]+t1); ...
分类:
其他好文 时间:
2015-01-13 19:58:24
阅读次数:
159
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [?2,1,?3,4,?1,2,1,?5,4],
the contiguous subarray [4,?1,2,1] ha...
分类:
其他好文 时间:
2015-01-12 13:07:22
阅读次数:
149