← All problemsSign in

3573. Best Time to Buy and Sell Stock V

LeetCodeArrayDynamic ProgrammingOpen on judge ↗

You are given an integer array prices where prices[i] is the price of a stock in dollars on the ith day, and an integer k. You are allowed to make at most k transactions, where each transaction can be either of the following: - Normal transaction: Buy on day i, then sell on a later day j where i < j. You profit prices[j] - prices[i]. - Short selling transaction: Sell on day i, then buy back o

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start