Wednesday, February 25, 2015

Best Time to Buy and Sell Stock IV

Best Time to Buy and Sell Stock IV

 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 at most k transactions.
Note:
You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
Credits:
Special thanks to @Freezen for adding this problem and creating all test cases.


------------------ thinking -------------------------------
how to correctly use DP to solve this problem!!!!

https://oj.leetcode.com/discuss/25627/dp-o-kn-time-o-n-space-cpp-solution
https://oj.leetcode.com/discuss/25603/a-concise-dp-solution-in-java

No comments:

Post a Comment