I had optiver hackerrank round. The question was following. Anyone have any idea how can I solve this. The way I approached was too complicated and hard to track at some point, since was using many data structures at the same time.