188. Best Time to Buy and Sell Stock IV

dp

time: O(nk)

space: O(nk)

注意 n/2 這件事

more simple

因為其實只用到 i 天和 i-1 的資料, 所以第一維可以去掉

time: O(nk)

space: O(nk)

Last updated

Was this helpful?