Search
⌘K
Get Premium
Leetcode 188. Best Time to Buy and Sell Stock IV
Given a price array and integer k, maximize total profit using at most k non-overlapping buy-sell transactions (cannot hold multiple stocks simultaneously). This is a DP problem over days and transaction counts, with the key optimization that when k >= n/2 it reduces to the unlimited-transactions case solvable greedily.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.