Available question text
Given arrays prices and strategy, you may (once) replace any k consecutive actions by k/2 holds followed by k/2 sells to maximize the sum of strategy[i]*prices[i]; compute the maximum achievable profit. This reduces to original profit plus the maximum total "gain" over any length-k window (each day's gain = (new - old)*price, where new is 0 for the first k/2 and 1 for the last k/2), which can be found in linear time (n up to 1e5).
Related questions
Continue with questions that share topics or the same question type.
- Best Time to Buy and Sell Stock
Coding · Array · Dynamic Programming
- Best Time to Buy and Sell Stock II
Coding · Array · Dynamic Programming · Greedy
- Best Time to Buy and Sell Stock III
Coding
- Best Time to Buy and Sell Stock IV
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3652. Best Time to Buy and Sell Stock using Strategy
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source