Best Time to Buy and Sell Stock IV

Solution Code

Time Complexity

O(N K)

Space Complexity

O(K)