Description
Solutions
Submission
Earn the Most 🐝

Let's delve into the art of crafting an algorithm 😂, tailor-made for the exhilarating realm of currency trading. Picture a bustling marketplace where fortunes are won and lost with each passing day. Our algorithm, honed to perfection, is poised to navigate this volatile landscape with finesse.

Our journey begins with two essential components: "prices" and "strategy." The former, a tapestry of daily currency prices, while the latter serves as our guiding light, indicating whether to buy, sell, or hold our precious assets.

But here's where it gets intriguing. We're granted the power to tweak our strategy, to optimize our trading performance. How, you ask? By strategically selecting a range of consecutive days, precisely Mr."mrk" in length, and orchestrating a symphony of buying and selling within that span.

Imagine it as a conductor wielding a baton, shaping the melody of our trades. The first half of our chosen range, we keep in a state of anticipation, a silent hold, while in the latter half, we unleash the power of our convictions, executing sell orders with precision.

And what's our goal amidst this dance of numbers? It's simple yet profound: to maximize our total profit. We aim to strike a chord of prosperity, where the sum of our selling rates eclipses the sum of our buying rates, paving the way for wealth and prosperity.

But remember, in this realm of uncertainty, where fortunes can shift in the blink of an eye, one must tread carefully. Yet armed with strategy and insight, we embark on this odyssey, ready to seize the opportunities that lie ahead.

For original prompt, pls refer to source images ₍ᐢ. .ᐢ₎

Example 1:

Input:  prices = [2, 4, 1, 5, 10, 6], approach = [-1, 1, 0, 1, -1, 0], mrK = 4
Output: 18
Explanation:
Let's kick off by assessing the profit if we were to leave the algorithm untouched, without any modifications. Before any trades commence, the profit stands at 0. On Day 0: The algorithm's strategy indicates a buy operation (strategy[0] = -1), prompting the purchase of currency at the price of rates[0] = 2. This results in a profit of 0 - 2 = -2. On Day 1: The strategy dictates a sell operation (strategy[1] = 1), leading to the sale of currency at the price of rates[1] = 4. As a result, the profit now stands at -2 + 4 = 2.
Constraints:
    Unknown for now
Thumbnail 0
Thumbnail 1
Testcase

Result
Case 1

input:

output: