Tap here to switch tabs
Problem
Submissions

Problem: Best Time to Buy and Sell Stock IV

med
30 min
Try to solve the Best Time to Buy and Sell Stock IV problem.

Statement

Given an integer array prices where prices[i] represents the price of a stock on the ithi^{th} day, and an integer k, determine the maximum profit achievable by completing at most k transactions (i.e., buying at most k times and selling at most k times).

Note: Multiple transactions cannot be held simultaneously — the current stock must be sold before purchasing again.

Constraints:

  • 11 \leq k 102\leq 10^2

  • 11 \leq prices.length 103\leq 10^3

  • 00 \leq prices[i] 103\leq 10^3

Tap here to switch tabs
Problem
Submissions

Problem: Best Time to Buy and Sell Stock IV

med
30 min
Try to solve the Best Time to Buy and Sell Stock IV problem.

Statement

Given an integer array prices where prices[i] represents the price of a stock on the ithi^{th} day, and an integer k, determine the maximum profit achievable by completing at most k transactions (i.e., buying at most k times and selling at most k times).

Note: Multiple transactions cannot be held simultaneously — the current stock must be sold before purchasing again.

Constraints:

  • 11 \leq k 102\leq 10^2

  • 11 \leq prices.length 103\leq 10^3

  • 00 \leq prices[i] 103\leq 10^3