Question d’entretien chez J.P. Morgan

Which data structure is more suitable for this problem(based on the 1st written exercise)?