Given two integer arrays prices and strategy, where -1 indicates buying and 1 indicates selling, calculate the maximum possible profit.
A sell closes the most recent unmatched buy. You may complete at most two trades, and you may skip unprofitable trades. Return the maximum total profit.
prices and strategy are lists of equal length. Return an integer. If a sell has no unmatched buy, ignore it. If multiple buys occur before a sell, the sell uses the most recent buy.
def max_profit(prices, strategy):