Back to problems

Earn the Most

Algorithm · Tradedesk · Hard

We are modeling a sequence of daily currency prices and a corresponding strategy signal. You are given an array prices where prices[i] is the price on day i, and an array strategy of the same length, where strategy[i] indicates the action for day i: -1: buy 1: sell 0: hold (do nothing) You have the ability to modify the strategy for a single contiguous block of exactly k consecutive days. Within this block, the first half of the days (rounded down if k is odd) are forced to…

Checking your access…