Motorola MOTOTRBO analytics receives a sequence of daily price values. Given prices and a target, find both the most profitable single buy and sell transaction and a pair of distinct entries whose values sum to target.
You must buy before selling. Return a dictionary with three fields: profit, the maximum possible profit; trade, the [buy_index, sell_index] producing that profit; and pair, two indices whose values sum to target. If no profitable trade exists, return trade as [-1, -1] and profit as 0. If no valid pair exists, return pair as [-1, -1].
For ties, choose the lexicographically smallest index pair. A pair may not reuse the same array element. The input array is not sorted and must not be modified.
prices and an integer target.profit, trade, and pair.trade and pair contain zero-based indices.def best_trade_and_pair(prices, target):