Pergunta de entrevista da empresa Morgan Stanley

Which data structure is best to implement this?