TradeCore interview question

Task was very difficult and it needs a time to solve it