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).
You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
------------------ 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